-
Notifications
You must be signed in to change notification settings - Fork 801
pkp: po alternative to lookup via valueForKeyPath: #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ce3dc97
Initial version of pkp, a command to print out via keypaths
5ccee16
Add an error message, made class invocation more durable.
72adcb4
Fix help message, clean up python.
bea8bee
If there's no '.', just pass the command to po, and evaluate the firs…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ def lldbcommands(): | |
| FBPrintOnscreenTableViewCells(), | ||
| FBPrintInternals(), | ||
| FBPrintInstanceVariable(), | ||
| FBPrintKeyPath(), | ||
| ] | ||
|
|
||
| class FBPrintViewHierarchyCommand(fb.FBCommand): | ||
|
|
@@ -272,3 +273,24 @@ def run(self, arguments, options): | |
|
|
||
| printCommand = 'po' if ('@' in ivarTypeEncodingFirstChar) else 'p' | ||
| lldb.debugger.HandleCommand('{} (({} *)({}))->{}'.format(printCommand, objectClass, object, ivarName)) | ||
|
|
||
| class FBPrintKeyPath(fb.FBCommand): | ||
| def name(self): | ||
| return 'pkp' | ||
|
|
||
| def description(self): | ||
| return "Print out the value of the key path expression using -valueForKeyPath:" | ||
|
|
||
| def args(self): | ||
| return [ | ||
| fb.FBCommandArgument(arg='keypath', type='NSString *', help='The keypath to print'), | ||
| ] | ||
|
|
||
| def run(self, arguments, options): | ||
| if len(arguments[0].split('.')) == 1: | ||
| print '"' + arguments[0] + '" is not a keypath =(' | ||
| return | ||
|
|
||
| object, keypath = arguments[0].split('.', 1) | ||
| printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a previous commit you had it evaluating |
||
| lldb.debugger.HandleCommand(printCommand) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about treating this case as equal to
po? That way, we can all typepkpexcept when evaluating something fancy.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an interesting idea, to add durable-ness, but I think it'd need a lot more checks than the presence of a '.' to be worth implementing. IE, [UIApplication sharedApplication].keyWindow would still blow up. I'd rather blow up in all slightly-wrong scenarios just keep clarity of intent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my other comment. Personally, while debugging, I'd rather make things as convenient as possible :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, looking at it again, I totally agree.