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

Inject F-Script into application requires gdb #13

Open
abarnert opened this issue Dec 18, 2014 · 2 comments
Open

Inject F-Script into application requires gdb #13

abarnert opened this issue Dec 18, 2014 · 2 comments

Comments

@abarnert
Copy link

Recent versions of Xcode no longer come with a gdb symlink, so you have to use lldb instead.

While lldb does have synonyms for its commands that make everything work, its command-line arguments are different. You have to use --source rather than -command, and if you use -n you have to give it an argument (which also makes things simpler, because now you can just pass the process name as an argument instead of having to hack up the script with sed—or just use -p with the PID, which means no quoting issues).

If you don't need admin privileges, the whole thing can be an AppleScript:

tell application "System Events"
    unix id of the first process whose frontmost is true
end tell

Then pass the result to a shell script with input as arguments:

lldb --attach-pid "$*" <<EOF
p (char)[[NSBundle bundleWithPath:@"/Library/Frameworks/FScript.framework"] load]
p (void)[FScriptMenuItem insertInMainMenu]
detach
quit
EOF

If you do, then you can remove the first line of gdbtemp.txt (and rename it to lldbtemp.txt while you're at it) and replace the existing AppleScript with:

tell application "System Events"
    set pid to unix id of the first process whose frontmost is true
end tell

do shell script "lldb -attach-pid" & pid & " --source=/tmp/lldbtemp.txt" with administrator privileges

Personally, I've created an fscript-inject shell script:

#!/bin/bash
lldb --attach-pid "$1" <<EOF
p (char)[[NSBundle bundleWithPath:@"/Library/Frameworks/FScript.framework"] load]
p (void)[FScriptMenuItem insertInMainMenu]
detach
quit
EOF

So my workflow is just one AppleScript:

tell application "System Events"
    set pid to unix id of the first process whose frontmost is true
end tell

do shell script "fscript-inject " & pid with administrator privileges
@Kentzo
Copy link
Owner

Kentzo commented Dec 23, 2014

@abarnert Nice, could you pack it in a file? I'll attach it to releases.

@perfaram
Copy link

Alternatively, you can use SIMBL. See my project

@Kentzo Kentzo mentioned this issue Oct 22, 2015
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants