Created
December 21, 2018 01:37
-
-
Save Watson1978/b3fea89be86b48a78e46c41337b6c055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| ruby$target:::method-entry | |
| { | |
| printf("method: %s#%s\n", copyinstr(arg0), copyinstr(arg1)); | |
| } |
This file contains hidden or 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
| class Foo | |
| def hello | |
| puts 1 + 2 | |
| end | |
| end | |
| Foo.new.hello |
Author
macOS に標準でインストールされている Ruby 2.3 は DTrace が有効になっており、method-entry で Ruby で書いたメソッドの呼び出しを捕捉できる。
$ /usr/bin/ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
$ sudo dtrace -s $HOME/tmp/dtrace/method.d -c "/usr/bin/ruby $HOME/tmp/dtrace/test.rb"
dtrace: script '/Users/s-fujita/tmp/dtrace/method.d' matched 2 probes
3
dtrace: pid 58949 has exited
CPU ID FUNCTION:NAME
6 355140 vm_exec_core:method-entry method: RbConfig#expand
...(略)...
4 355140 vm_exec_core:method-entry method: Foo#hello
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.