Skip to content
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

Fix issue with visualize #244

Merged
merged 2 commits into from
Jun 5, 2018
Merged

Fix issue with visualize #244

merged 2 commits into from
Jun 5, 2018

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Jun 5, 2018

Fixes #215 and #177.

UIImagePNGRepresentation() is apparently multithreaded. However, by default Chisel disables other threads from running when evaluating expressions. This change exposes a keyword argument, tryAllThreads, which lets commands like visualize specify that certain expressions be evaluated with multithreading permitted.

Note that calling visualize with an Optional type will require unwrapping it. For example:

visualize icon.image()!

cc @cbowns

@cbowns
Copy link

cbowns commented Jun 5, 2018

Dropped this on top of my current checkout of 1.8.0, but I got:

(lldb) visualize icon.image()!
Traceback (most recent call last):
  File "/usr/local/opt/chisel/libexec/fblldb.py", line 84, in runCommand
    command.run(args, options)
  File "/usr/local/Cellar/chisel/1.8.0/libexec/commands/FBVisualizationCommands.py", line 179, in run
    _visualize(arguments[0])
  File "/usr/local/Cellar/chisel/1.8.0/libexec/commands/FBVisualizationCommands.py", line 151, in _visualize
    _showImage(target)
  File "/usr/local/Cellar/chisel/1.8.0/libexec/commands/FBVisualizationCommands.py", line 38, in _showImage
    imageDataAddress = fb.evaluateExpressionValue(toPNG, tryAllThreads=True).GetValue()
TypeError: evaluateExpressionValue() got an unexpected keyword argument 'tryAllThreads'

I'll make sure I have all the files from master

@kastiglione
Copy link
Contributor Author

From your (lldb) prompt, what is the output of:

script print sys.modules["fblldbbase"], sys.modules["FBVisualizationCommands"]

@cbowns
Copy link

cbowns commented Jun 5, 2018

<module 'fblldbbase' from '/usr/local/opt/chisel/libexec/fblldbbase.py'> <module 'FBVisualizationCommands' from '/usr/local/Cellar/chisel/1.8.0/libexec/commands/FBVisualizationCommands.py'>

@cbowns
Copy link

cbowns commented Jun 5, 2018

I checked that sudo make installed, though: I moved my brew install aside

cbowns at cbowns-mbp143 in /usr/local/Cellar/chisel ☆
% ○ diff -r 1.8.0 1.8.0-from-brew                                                                                                                                                               2018-06-05 [13:14:33]
Binary files 1.8.0/.DS_Store and 1.8.0-from-brew/.DS_Store differ
Binary files 1.8.0/lib/Chisel.framework/Chisel and 1.8.0-from-brew/lib/Chisel.framework/Chisel differ
Binary files 1.8.0/lib/Chisel.framework/Info.plist and 1.8.0-from-brew/lib/Chisel.framework/Info.plist differ
diff -r 1.8.0/lib/Chisel.framework/_CodeSignature/CodeResources 1.8.0-from-brew/lib/Chisel.framework/_CodeSignature/CodeResources
13c13
< 		ihfybMclsZuGec4fe2GGj8kzYbU=
---
> 		vNNdYuweFSD0N7zzj3A/07pifWw=
Only in 1.8.0-from-brew/libexec/commands: .DS_Store
Only in 1.8.0/libexec/commands: FBVisualizationCommands-old.py
diff -r 1.8.0/libexec/commands/FBVisualizationCommands.py 1.8.0-from-brew/libexec/commands/FBVisualizationCommands.py
37,38c37
<   toPNG = '(id)UIImagePNGRepresentation((id){})'.format(commandForImage)
<   imageDataAddress = fb.evaluateExpressionValue(toPNG, tryAllThreads=True).GetValue()
---
>   imageDataAddress = fb.evaluateObjectExpression('UIImagePNGRepresentation((id)' + commandForImage + ')')
Only in 1.8.0/libexec: fblldbbase-old.py
diff -r 1.8.0/libexec/fblldbbase.py 1.8.0-from-brew/libexec/fblldbbase.py
59c59
< def evaluateExpressionValue(expression, printErrors=True, language=lldb.eLanguageTypeObjC_plus_plus, tryAllThreads=False):
---
> def evaluateExpressionValue(expression, printErrors=True, language=lldb.eLanguageTypeObjC_plus_plus):
73,74c73,74
<   # Most Chisel commands are not multithreaded.
<   options.SetTryAllThreads(tryAllThreads)
---
>   # Chisel commands are not multithreaded.
>   options.SetTryAllThreads(False)

@cbowns
Copy link

cbowns commented Jun 5, 2018

jk looks great. (I completely shut down Xcode and relaunched it. I think it caches some/all of the lldb imports?)

@kastiglione
Copy link
Contributor Author

kastiglione commented Jun 5, 2018

<module 'fblldbbase' from '/usr/local/opt/chisel/libexec/fblldbbase.py'> <module 'FBVisualizationCommands' from '/usr/local/Cellar/chisel/1.8.0/libexec/commands/FBVisualizationCommands.py'>

Ah, different versions for those two modules. Try stopping the debug session, running pkill lldb-rpc-server, and then running the app again.

@kastiglione kastiglione merged commit 365e758 into master Jun 5, 2018
@kastiglione kastiglione deleted the fix-visualize branch June 5, 2018 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants