Skip to content
Merged
Changes from 3 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
25 changes: 25 additions & 0 deletions commands/FBPrintCommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def lldbcommands():
FBPrintInternals(),
FBPrintInstanceVariable(),
FBPrintKeyPath(),
FBPrintApplicationDocumentsPath(),
]

class FBPrintViewHierarchyCommand(fb.FBCommand):
Expand Down Expand Up @@ -299,3 +300,27 @@ def run(self, arguments, options):
object = fb.evaluateObjectExpression(objectToMessage)
printCommand = 'po [{} valueForKeyPath:@"{}"]'.format(object, keypath)
lldb.debugger.HandleCommand(printCommand)


class FBPrintApplicationDocumentsPath(fb.FBCommand):
def name(self):
return 'pdocspath'

def description(self):
return "Print application's 'Documents' directory path."

def options(self):
return [
fb.FBCommandArgument(short='-o', long='--open', arg='open', boolean=True, default=False, help='open in Finder'),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

]

def run(self, arguments, options):
if options.open:
path = fb.evaluateExpressionValue('(NSString *)[NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make constants for these numbers?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use evaluateObjectExpression() instead of evaluateExpressionValue(), which would make the NSString cast unnecessary.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kastiglione hi I tried evaluateObjectExpression() and evaluateExpression() but only get pointer value instead of string value so I keep using evaluateExpressionValue() and split the string output in the new implementation. Am I missing something?

pathString = '{}'.format(path).split('"')[1]
print pathString
lldb.debugger.HandleCommand('script os.system("open {}")'.format(pathString))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can call os.system() directly, it's not necessary to call it via HandleCommand().

else:
lldb.debugger.HandleCommand('po [NSSearchPathForDirectoriesInDomains(9, 1, YES) lastObject]') # NSDocumentDirectory == 9 NSUserDomainMask == 1