Created
February 8, 2012 17:37
-
-
Save jrun/1771529 to your computer and use it in GitHub Desktop.
Using dtrace, trace method calls for a given, fully qualified module. If a module is not given all method calls are traced.
This file contains 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
#!/usr/bin/env ruby | |
# This script requires the traced Ruby process to be tenderlove's probes | |
# branch (https://github.com/tenderlove/ruby-1/tree/probes). | |
fq_module = ARGV[0] | |
d_script = "ruby*:::function-entry\n" | |
d_script << "/copyinstr(arg0) == \"#{fq_module}\"/\n" if fq_module | |
d_script << <<-ACTION | |
{ | |
printf("%s[%d] %s %s %s:%d\\n", execname, pid, copyinstr(arg0), copyinstr(arg1), copyinstr(arg2), arg3); | |
} | |
ACTION | |
exec "sudo dtrace -q -n '#{d_script}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The update version is kept in my dotfiles