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

Implement findinstances command #216

Merged
merged 7 commits into from
Jan 4, 2018
Merged

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented Jan 3, 2018

This pull requests adds the findinstances command, which completes the work from #197 and #214.

For details on findinstances users can run help findinstances. The brief summary is that findinstances can find all instances of a given class or protocol, and can filter those results, using a predicate expression.

If you had a class named XXSocialUser, then you could for example find a specific user by running findinstances XXSocialUser username == 'curry'.

@kastiglione
Copy link
Contributor Author

@keith wanna try this and let me know if it works for you?

@keith
Copy link
Contributor

keith commented Jan 4, 2018

I'm actually hitting the Unknown error loading Chisel code path, which is quite strange. I will try and debug more.

@kastiglione
Copy link
Contributor Author

Interesting. I can work with you on that.

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

I wonder if perror() would shed any more light.

@kastiglione
Copy link
Contributor Author

Are you using CHISEL_LIBRARY_PATH or did you install it into the homebrew path? If using the environment variable, what path is the library?

@kastiglione
Copy link
Contributor Author

I added errno handling, which may help figure out the issue @keith.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

This is what I'm currently getting installing via homebrew

error: error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=50, address=0x123138000).
The process has been returned to the state before expression evaluation.
error: error: Execution was interrupted, reason: signal SIGKILL.
The process has been returned to the state before expression evaluation.
error: warning: got name from symbols: errno
error: cast from pointer to smaller type 'int' loses information
Unknown error loading Chisel

@kastiglione
Copy link
Contributor Author

Ah yes, code=50. This comes back to my question about code signing. That 50 is KERN_CODESIGN_ERROR.

So you installed via a local change to the chisel recipe?

If you re-codesign the library in it's installed location, does that fix the problem? The xcodebuild output will show the codesign command.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

Ah yes. So the binary is signed from the homebrew install. I've added this command to make it work with brew edit Chisel:

    system "make", "-C", "Chisel", "install", "PREFIX=#{lib}"

But re-signing it does fix the problem, which is interesting.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

Also I noticed if you run findinstances with no arguments, it fails:

(lldb) findinstances
Traceback (most recent call last):
  File "/usr/local/opt/chisel/libexec/fblldb.py", line 83, in runCommand
    command.run(args, options)
  File "/usr/local/Cellar/chisel/HEAD-76dfc8a/libexec/commands/FBDebugCommands.py", line 235, in run
    args = arguments[0].strip().split(' ', 1)
IndexError: list index out of range

It might be nice to have a nicer help message or something here

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

Does homebrew build in a chroot and then copy out?

@kastiglione
Copy link
Contributor Author

But re-signing it does fix the problem, which is interesting.

I wasted too much time over this. Where should the codesign command be added, the homebrew recipe?

@kastiglione
Copy link
Contributor Author

run findinstances with no arguments, it fails

should be fixed in 4ae2ba7

@kastiglione
Copy link
Contributor Author

oh wait, just looked at the trace you gave, maybe not.

@kastiglione
Copy link
Contributor Author

New fix 5865969. I actually ran it this time.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

If we did add a codesign call in the formulae I'm not sure what signature you would use though

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

Do you mean which signing identity? If not, I don't follow.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

Yes which signing identity for it to be valid, when I built manually the adhoc one that was used was valid.

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

Shouldn't it always be ad hoc? Do simulator builds ever not use ad hoc? The Makefile you added will always use ad hoc (right?), so resigning with ad hoc seems equal in intent.

@kastiglione
Copy link
Contributor Author

When you install using your local recipe (without further modifications), what is the result of:

codesign -v -d /usr/local/Cellar/chisel/1.6.0/lib/Chisel.framework/Chisel

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

Note I'm not sure if my last question is useful for anything, feel free to ignore.

My hypothesis is that the homebrew recipe needs a post-install step that runs codesign -s -.

@keith
Copy link
Contributor

keith commented Jan 4, 2018

Executable=/usr/local/Cellar/chisel/HEAD-5865969/lib/Chisel.framework/Chisel
Identifier=com.facebook.Chisel
Format=bundle with Mach-O universal (i386 x86_64)
CodeDirectory v=20100 size=420 flags=0x2(adhoc) hashes=8+3 location=embedded
Signature=adhoc
Info.plist entries=20
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=2
Internal requirements count=0 size=12

@kastiglione
Copy link
Contributor Author

kastiglione commented Jan 4, 2018

Looks the same as mine, except for the path. In my case, mine was installed using the Makefile, but I ran it myself from the a regular terminal session, not via homebrew. I'm wondering if homebrew runs the make command in a chroot, then copies it to /usr/local, and if that's what breaks the signing. Try running the make command yourself, with PREFIX=/usr/local/Cellar/chisel/HEAD-5865969/lib.

@kastiglione
Copy link
Contributor Author

#217 is the fix for the code signing problems discussed here.

@kastiglione
Copy link
Contributor Author

works for @keith now

@kastiglione kastiglione merged commit 0740627 into master Jan 4, 2018
@kastiglione kastiglione deleted the findinstances-command branch January 4, 2018 23:47
@keith
Copy link
Contributor

keith commented Jan 4, 2018

🎉

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