Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TracePoint Tips Talk
Search
Shuichi Tamayose
March 10, 2018
Technology
1
740
TracePoint Tips Talk
Ruby の TracePoint についてサンプルコードを混ぜながら紹介します。
Shuichi Tamayose
March 10, 2018
Tweet
Share
More Decks by Shuichi Tamayose
See All by Shuichi Tamayose
Hitachi Hokudai Lab. & Hokkaido University Contest 2022 B問題解説
siman
0
94
railsdm2019.pdf
siman
2
770
Qiita の記事の typo を 1ヶ月間直し続けた話
siman
0
600
Other Decks in Technology
See All in Technology
エンジニアが一生困らない ドキュメント作成の基本
naohiro_nakata
2
140
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
0
1.1k
RAGのためのビジネス文書解析技術
eida
3
660
第23回Ques_タイミーにおけるQAチームの在り方 / QA Team in Timee
takeyaqa
0
190
Lexical Analysis
shigashiyama
1
130
Microsoft Intune アプリのトラブルシューティング
sophiakunii
1
400
Datadog RUM を用いた UX 指標の監視・顧客対応への活用
imamura_ko_0314
0
110
Redmine 6.0 新機能評価ガイド
vividtone
0
260
State of Open Source Web Mapping Libraries
dayjournal
0
200
SREの組織類型に応じた リーダシップの考察
kenta_hi
PRO
0
620
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
1
220
いろんなものと両立する Kaggleの向き合い方
go5paopao
2
970
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
231
17k
Documentation Writing (for coders)
carmenintech
65
4.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
360
GitHub's CSS Performance
jonrohan
1030
460k
Optimizing for Happiness
mojombo
376
69k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Agile that works and the tools we love
rasmusluckow
327
21k
BBQ
matthewcrist
85
9.3k
Building Adaptive Systems
keathley
38
2.3k
Transcript
TracePoint Tips Talk 2018/03/10 () ԭೄRubyձٞ02 ླྀٿେֶ ֶ෦ 1 ߸ؗ
େڭࣨ 321 / 322
ࣗݾհ ໊લ : ۄد मҰ ॴଐ : YassLab גࣜձࣾ Twitter
: @_simanman GitHub : siman-man Rubyྺ : 7͙Β͍
TracePoint ͬͯ·͔͢
TracePointʹ͍ͭͯ ɾRuby ͷΈࠐΈͷΫϥε ɾRuby 2.0 ͔Βར༻Մೳ ɾRuby ͷ༷ʑͳΠϕϯτΛϑοΫग़དྷΔ ɾ໊͕ڪΖ͍͘͠
TracePointʹ͍ͭͯ ɾRuby 2.0 ͔Βར༻Մೳ ɾRuby ͷΈࠐΈͷΫϥε ɾRuby ͷ༷ʑͳΠϕϯτΛϑοΫग़དྷΔ ɾ໊͕ڪΖ͍͘͠
TracePointʹ͍ͭͯ ɾRuby ͷΈࠐΈͷΫϥε ɾRuby 2.0 ͔Βར༻Մೳ ɾRuby ͷ༷ʑͳΠϕϯτΛϑοΫग़དྷΔ ɾ໊͕ڪΖ͍͘͠
TracePointʹ͍ͭͯ ɾRuby ͷΈࠐΈͷΫϥε ɾRuby 2.0 ͔Βར༻Մೳ ɾRuby ͷ༷ʑͳΠϕϯτΛϑοΫग़དྷΔ ɾ໊͕ڪΖ͍͘͠
TracePointʹ͍ͭͯ ɾRuby ͷΈࠐΈͷΫϥε ɾRuby 2.0 ͔Βར༻Մೳ ɾRuby ͷ༷ʑͳΠϕϯτΛϑοΫग़དྷΔ ɾ໊͕ڪΖ͍͘͠
໊ͷ͞ "ΫοΫύου։ൃऀϒϩά", "Ruby 2.5 ͷվળΛࣗຫ͍ͨ͠", http://techlife.cookpad.com/entry/2017/12/28/113839
໊ͷ͞ "ΫοΫύου։ൃऀϒϩά", "Ruby 2.5 ͷվળΛࣗຫ͍ͨ͠", http://techlife.cookpad.com/entry/2017/12/28/113839
໊ͷ͞ "ΫοΫύου։ൃऀϒϩά", "Ruby 2.5 ͷվળΛࣗຫ͍ͨ͠", http://techlife.cookpad.com/entry/2017/12/28/113839
ൃද༰ ɾαϯϓϧίʔυͷհ ɾTracePoint ʹ͍ͭͯͷհ
ൃද༰ ɾαϯϓϧίʔυͷհ ɾTracePoint ʹ͍ͭͯͷհ
TracePoint ʹ͍ͭͯ ৭ʑͳΠϕϯτΛϑοΫͰ͖ΔΑ͏ʹͳΔศརػೳ
Ruby ʹଘࡏ͢Δ༷ʑͳϑοΫϝιου Πϕϯτ ݺͼग़͞ΕΔλΠϛϯά method_missing ଘࡏ͠ͳ͍ϝιου͕ݺͼग़͞Εͨ࣌ const_missing ଘࡏ͠ͳ͍ఆΛࢀরͨ࣌͠ respond_to_missing? respond_to?
ͷ݁Ռ͕ false ͷ࣌ method_added ϝιου͕Ճ͞Εͨ࣌ method_removed ϝιου͕ remove_method ʹΑͬͯআ͞Εͨ࣌ method_undefined ϝιου͕ undef_method ͔ undef ʹΑͬͯআ͞Εͨ࣌ singleton_method_added ಛҟϝιου͕Ճ͞Εͨ࣌ singleton_method_removed ಛҟϝιου͕ remove_method ʹΑͬͯআ͞Εͨ࣌ singleton_method_undefined ಛҟϝιου͕ undef_method ͔ undef ʹΑͬͯআ͞Εͨ࣌ prepend_features Module#prepend ͷ࣮ମ prepended Module#prepend ͨ͠ޙ append_features Module#include ͷ࣮ମ included Module#include ͨ͠ޙ extend_object Object#extend ͷ࣮ମ extended Object#extend ͨ͠ޙ inherited ΫϥεͷαϒΫϥε͕ఆٛ͞Εͨ࣌ at_exit ϓϩάϥϜऴྃ࣌ "Qiita", "Ruby ͰϑοΫͰ͖ΔΠϕϯτҰཡ", https://qiita.com/siman/items/b6895d0826d5e83fd9cb
TracePoint Ͱ͞Βʹ৭ʑͳΠϕϯτ͕ϑοΫՄೳʹͳΔ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html Πϕϯτ આ໌ :line
ࣜͷධՁ :class ΫϥεఆٛɺಛҟΫϥεఆٛɺϞδϡʔϧఆٛͷಥೖ :end ΫϥεఆٛɺಛҟΫϥεఆٛɺϞδϡʔϧఆٛͷऴྃ :call Ruby Ͱهड़͞Εͨϝιουͷݺͼग़͠ :return Ruby Ͱهड़͞Εͨϝιουݺͼग़͔͠ΒͷϦλʔϯ :c_call C Ͱهड़͞Εͨϝιουͷݺͼग़͠ :c_return CͰهड़͞Εͨϝιουݺͼग़͔͠ΒͷϦλʔϯ :raise ྫ֎ͷൃੜ :b_call ϒϩοΫͷ։࢝ :b_return ϒϩοΫͷऴྃ :thread_begin εϨουͷ։࢝ :thread_end εϨουͷऴྃ :fiber_switch ϑΝΠόʔͷΓସ͑
TracePoint Ͱ͞Βʹ৭ʑͳΠϕϯτ͕ϑοΫՄೳʹͳΔ Πϕϯτ આ໌ :line ࣜͷධՁ :class ΫϥεఆٛɺಛҟΫϥεఆٛɺϞδϡʔϧఆٛͷಥೖ :end ΫϥεఆٛɺಛҟΫϥεఆٛɺϞδϡʔϧఆٛͷऴྃ
:call Ruby Ͱهड़͞Εͨϝιουͷݺͼग़͠ :return Ruby Ͱهड़͞Εͨϝιουݺͼग़͔͠ΒͷϦλʔϯ :c_call C Ͱهड़͞Εͨϝιουͷݺͼग़͠ :c_return CͰهड़͞Εͨϝιουݺͼग़͔͠ΒͷϦλʔϯ :raise ྫ֎ͷൃੜ :b_call ϒϩοΫͷ։࢝ :b_return ϒϩοΫͷऴྃ :thread_begin εϨουͷ։࢝ :thread_end εϨουͷऴྃ :fiber_switch ϑΝΠόʔͷΓସ͑ ࠓճհग़དྷΔͷ͘͝Θ͔ͣ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
TracePoint Ͱ͑Δϝιου ϝιου໊ આ໌ binding binding ΦϒδΣΫτΛฦ͢ defined_class ϝιουΛఆٛͨ͠Ϋϥε͔ϞδϡʔϧΛฦ͢ disable
τϨʔεΛແޮʹ͢Δ enable τϨʔεΛ༗ޮʹ͢Δ enabled? τϨʔε͕༗ޮ͔Ͳ͏͔ΛௐΔ event ൃੜͨ͠ΠϕϯτͷछྨΛฦ͢ inspect self ͷঢ়ଶΛਓ͕ؒಡΈ͍͢ͷʹͯ͘͠ΕΔ lineno Πϕϯτ͕ൃੜͨ͠ߦ൪߸Λฦ͢ method_id Πϕϯτ͕ൃੜͨ͠ϝιου໊Λฦ͢ path Πϕϯτ͕ൃੜͨ͠ϑΝΠϧͷύεΛฦ͢ raised_exception ൃੜͨ͠ྫ֎Λฦ͢ return_value ϝιουϒϩοΫͷΓΛฦ͢ self ΠϕϯτΛൃੜͤͨ͞ΦϒδΣΫτΛฦ͢ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
TracePoint Ͱ͑Δϝιου ϝιου໊ આ໌ binding binding ΦϒδΣΫτΛฦ͢ defined_class ϝιουΛఆٛͨ͠Ϋϥε͔ϞδϡʔϧΛฦ͢ disable
τϨʔεΛແޮʹ͢Δ enable τϨʔεΛ༗ޮʹ͢Δ enabled? τϨʔε͕༗ޮ͔Ͳ͏͔ΛௐΔ event ൃੜͨ͠ΠϕϯτͷछྨΛฦ͢ inspect self ͷঢ়ଶΛਓ͕ؒಡΈ͍͢ͷʹͯ͘͠ΕΔ lineno Πϕϯτ͕ൃੜͨ͠ߦ൪߸Λฦ͢ method_id Πϕϯτ͕ൃੜͨ͠ϝιου໊Λฦ͢ path Πϕϯτ͕ൃੜͨ͠ϑΝΠϧͷύεΛฦ͢ raised_exception ൃੜͨ͠ྫ֎Λฦ͢ return_value ϝιουϒϩοΫͷΓΛฦ͢ self ΠϕϯτΛൃੜͤͨ͞ΦϒδΣΫτΛฦ͢ ͪ͜Βࠓճհग़དྷΔͷ͘͝Θ͔ͣ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
Binding Ͱ͑Δϝιου ϝιου໊ આ໌ eval self ΛίϯςΩετͱͯ͠͞ΕͨจࣈྻΛධՁͦ͠ͷ݁ՌΛฦ͢ local_variable_defined? ҾͰ͞Ε໊ͨલͷม͕ఆٛ͞Ε͍ͯΔ͔Ͳ͏͔Λఆ͢Δ local_variable_get
ҾͰ͞Ε໊ͨલͷมͷΛऔಘ͢Δ local_variable_set ୈҰҾͰࢦఆ໊ͨ͠લͷมʹୈೋҾͰ͞ΕͨΛઃఆ͢Δ local_variables ϩʔΧϧมͷҰཡΛऔಘ͠·͢ receiver อ࣋͢ΔίϯςΩετͰͷ self Λฦ͠·͢ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
Binding Ͱ͑Δϝιου ϝιου໊ આ໌ eval self ΛίϯςΩετͱͯ͠͞ΕͨจࣈྻΛධՁͦ͠ͷ݁ՌΛฦ͢ local_variable_defined? ҾͰ͞Ε໊ͨલͷม͕ఆٛ͞Ε͍ͯΔ͔Ͳ͏͔Λఆ͢Δ local_variable_get
ҾͰ͞Ε໊ͨલͷมͷΛऔಘ͢Δ local_variable_set ୈҰҾͰࢦఆ໊ͨ͠લͷมʹୈೋҾͰ͞ΕͨΛઃఆ͢Δ local_variables ϩʔΧϧมͷҰཡΛऔಘ͠·͢ receiver อ࣋͢ΔίϯςΩετͰͷ self Λฦ͠·͢ ޙ΄Ͳొ "TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
τϨʔεͷ։࢝ํ๏
τϨʔεͷ։࢝ํ๏ 1. trace Λར༻ͯ͠։࢝͢Δ 2. TracePoint ΦϒδΣΫτΛ࡞ͯ͠ enable Ͱ։࢝͢Δ
τϨʔεͷ։࢝ํ๏ 2. ෳͷΠϕϯτΛࢦఆ͢Δ͜ͱ͕Մೳ 1. ҾͰϑοΫ͍ͨ͠ΠϕϯτΛࢦఆग़དྷΔ
ͱ͜ΖͰ
https://twitter.com/mametter/status/966539432366030850
౸ୡෆՄೳʹݟ͑Δ͕... https://twitter.com/mametter/status/966539432366030850
1ͭͷղ๏ ౸ୡͰ͖Δɻͦ͏ɺTracePoint ͳΒͶɻ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ :line ࣜͷධՁ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
ΠϕϯτൃੜϙΠϯτ :line ࣜͷධՁ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ ϝιου͕ݺͼग़͞ΕΔ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ if ࣜʹ౸ண Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ ͷ෦͕࣮ߦ͞ΕΔ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ ϝιου໊ આ໌ binding binding ΦϒδΣΫτΛฦ͢ lineno Πϕϯτ͕ൃੜͨ͠ߦ൪߸Λฦ͢ ར༻͍ͯ͠Δ TracePoint
ͷϝιου ϝιου໊ આ໌ local_variable_set ୈҰҾͰࢦఆ໊ͨ͠લͷมʹୈೋҾͰ͞ΕͨΛઃఆ͢Δ ར༻͍ͯ͠Δ Binding ͷϝιου Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ local_variable_set Λͬͯ x ͷΛॻ͖ม͑Δ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ x ͷ true ʹͳ͍ͬͯΔͷͰ if ͷ݅Λύε͢Δ Qiita, "RubyͰif xʹωετͨ͠unless
xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ unless ࣜʹ౸ୡ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ ࠶ local_variable_set Λ༻ͯ͠ x Λ false ʹॻ͖ม͑ Qiita, "RubyͰif
xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ x ͷ false ʹͳ͍ͬͯΔͷͰ unless ͷ݅Λύε͢Δ Qiita, "RubyͰif xʹωετͨ͠unless
xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
1ͭͷղ๏ ແࣄ౸ୡʂ Qiita, "RubyͰif xʹωετͨ͠unless xͷதʹ࣮ߦ౸ୡ͢Δํ๏", https://qiita.com/hanachin_/items/4415c178f2980aa23dd6
ൃද༰ ɾαϯϓϧίʔυͷհ ɾTracePoint ʹ͍ͭͯͷհ
αϯϓϧίʔυͷհ ɾܕνΣοΫ ɾίʔϧελοΫΛදࣔ͢Δ
αϯϓϧίʔυͷհ ɾܕνΣοΫ ɾίʔϧελοΫΛදࣔ͢Δ
ίʔϧελοΫΛදࣔ͢Δ "GitHub", "method_call_tree", https://github.com/siman-man/method_call_tree ͜Μͳײ͡ͰίʔυΛॻ͘ͱ
ίʔϧελοΫΛදࣔ͢Δ ͜Μͳײ͡Ͱදࣔ͞ΕΔ "GitHub", "method_call_tree", https://github.com/siman-man/method_call_tree
ίʔϧελοΫΛදࣔ͢Δ ͜Μͳײ͡ͰίʔυΛॻ͘ͱ "GitHub", "method_call_tree", https://github.com/siman-man/method_call_tree
ίʔϧελοΫΛදࣔ͢Δ ͜Μͳײ͡Ͱදࣔ͞ΕΔ ͜Μͳײ͡ͰίʔυΛॻ͘ͱ "GitHub", "method_call_tree", https://github.com/siman-man/method_call_tree
Έʹ͍ͭͯ αϯϓϧ༻ίʔυ ຊମίʔυ method_call_tree ෦Ͱ͏গ͠ෳࡶʹͳ͍ͬͯΔ
Έʹ͍ͭͯ Foo#fooͷݺͼग़͠
Έʹ͍ͭͯ call ΠϕϯτΛड͚औΔ
Έʹ͍ͭͯ Ͳ͔͜Βݺͼग़͞Ε͔ͨΛจࣈྻͰදݱ ࠓճͷྫͩͱ "ݺͼग़͠ݩͷΫϥε" + "ϝιου໊" "Foo::foo"
Έʹ͍ͭͯ ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ
Έʹ͍ͭͯ tree = { } ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ
Έʹ͍ͭͯ tree = { "Foo::foo": { } } ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ
Έʹ͍ͭͯ call_stack ʹ key ΛՃ Foo::foo
Έʹ͍ͭͯ Foo::foo call_stack ʹ key ΛՃ
Έʹ͍ͭͯ Foo#barͷݺͼग़͠
Έʹ͍ͭͯ call ΠϕϯτΛड͚औΔ
Έʹ͍ͭͯ Ͳ͔͜Βݺͼग़͞Ε͔ͨΛจࣈྻͰදݱ "Foo::bar"
Έʹ͍ͭͯ tree = { "Foo::foo": { } } ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ Foo::foo
Έʹ͍ͭͯ tree = { "Foo::foo": { } } ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ Foo::foo
Έʹ͍ͭͯ tree = { "Foo::foo": { } } ݺͼग़͞ΕํΛϋογϡͷωετͰදݱ Foo::foo
Έʹ͍ͭͯ tree = { "Foo::foo": { "Foo::bar": { } }
} Foo::foo
Έʹ͍ͭͯ call_stack ʹ key ΛՃ Foo::bar Foo::foo
Έʹ͍ͭͯ Foo::foo Foo::bar call_stack ʹ key ΛՃ
Έʹ͍ͭͯ Foo#barͷݺͼग़͕͠ऴྃ
Έʹ͍ͭͯ return ΠϕϯτΛड͚औΔ
Έʹ͍ͭͯ call_stack ͔Β key ΛऔΓग़͢ Foo::foo Foo::bar
Έʹ͍ͭͯ call_stack ͔Β key ΛऔΓग़͢ Foo::foo
Έʹ͍ͭͯ ͜ͷૢ࡞Λ࠷ޙ·ͰਐΊΔͱɻɻɻ
Έʹ͍ͭͯ tree = { "Foo::foo": { "Foo::bar": { }, "Foo::baz":
{ "Foo::hoge": { } } } } ࠷ऴతͳ tree ͷ͕͜͏ͳΔ
Έʹ͍ͭͯ tree ίϚϯυͬΆ͘දࣔͤ͞Δ tree = { "Foo::foo": { "Foo::bar": {
}, "Foo::baz": { "Foo::hoge": { } } } }
αϯϓϧίʔυͷհ ɾܕνΣοΫ ɾίʔϧελοΫΛදࣔ͢Δ
ܕνΣοΫ ɾϝιουͷฦΓΛௐΔ ɾϝιουͷҾͷΛௐΔ
ܕνΣοΫ ɾϝιουͷฦΓΛௐΔ ɾϝιουͷҾͷΛௐΔ
ϝιουͷҾͷΛௐΔ ࣮ߦ݁Ռ ҾΛௐΔͨΊͷίʔυ
ϝιουͷҾͷΛௐΔ ϝιου໊ આ໌ eval self ΛίϯςΩετͱͯ͠͞ΕͨจࣈྻΛධՁͦ͠ͷ݁ՌΛฦ͢ local_variable_get ҾͰ͞Ε໊ͨલͷมͷΛऔಘ͢Δ ར༻͍ͯ͠Δ Binding
ͷϝιου
ϝιουͷҾͷΛௐΔ ϝιου໊ આ໌ eval self ΛίϯςΩετͱͯ͠͞ΕͨจࣈྻΛධՁͦ͠ͷ݁ՌΛฦ͢ local_variable_get ҾͰ͞Ε໊ͨલͷมͷΛऔಘ͢Δ ར༻͍ͯ͠Δ Binding
ͷϝιου ྗٕͰҾͷҰཡΛऔΔ
ϝιουͷҾͷΛௐΔ ϝιου໊ આ໌ eval self ΛίϯςΩετͱͯ͠͞ΕͨจࣈྻΛධՁͦ͠ͷ݁ՌΛฦ͢ local_variable_get ҾͰ͞Ε໊ͨલͷมͷΛऔಘ͢Δ ར༻͍ͯ͠Δ Binding
ͷϝιου ͜ͷۭؒʹ͍ΔલఏͰධՁ͞ΕΔ
ҾͷҰཡΛऔಘ [:message] ϝιουͷҾͷΛௐΔ
ϝιουͷҾͷΛௐΔ มͷΛௐΔ
ϝιουͷҾͷΛௐΔ ݁ՌΛग़ྗ͢Δ
ܕνΣοΫ ɾϝιουͷฦΓΛௐΔ ɾϝιουͷҾͷΛௐΔ
ϝιουͷฦΓΛௐΔ ࣮ߦ݁Ռ ฦΓΛௐΔͨΊͷίʔυ
ϝιου໊ આ໌ return_value ϝιουϒϩοΫͷΓΛฦ͢ ར༻͍ͯ͠Δ TracePointͷϝιου ϝιουͷฦΓΛௐΔ
ܕνΣοΫ ͪͳΈʹ
return_value ͷॻ͖͑ return_value ͷΛഁյతʹมߋ͢Δ͜ͱͰɺϝιουͷฦΓΛม͑Δ͜ͱ͕ग़དྷΔ upcase ͍ͯ͠Δͷʹখจࣈ͕ग़ྗ͞ΕΔ
͜Μͳόάʹग़ձͬͯ upcase ͍ͯ͠Δͷʹখจࣈ͕ฦͬͯ͘Δ...
TracePoint Λ͍ͬͯΔͱແࣄղܾ TracePoint Ͱ c_return ͷΠϕϯτΛϑοΫͯ͠ɺ method_id ͕ "upcase" ͷ߹ʹ
return_value ͷΛ downcase! Ͱഁյతʹมߋ͍ͯͨ͠ͷ͕ݪҼ͔ʙ Α͔ͬͨʂ
ܕνΣοΫ ؆қతʹܕνΣοΫΛߦͳ͏αϯϓϧίʔυ string2symbol ͕จࣈྻΛҾʹͱͬͯγϯϘϧΛฦ͢͜ͱΛظ͢Δ
ܕνΣοΫ ؆қతʹܕνΣοΫΛߦͳ͏αϯϓϧίʔυ string2symbol ͕จࣈྻΛҾʹͱͬͯγϯϘϧΛฦ͢͜ͱΛظ͢Δ จࣈྻΛड͚औͬͯ Symbol Λฦ͢
ܕνΣοΫ ؆қతʹܕνΣοΫΛߦͳ͏αϯϓϧίʔυ string2symbol ͕จࣈྻΛҾʹͱͬͯγϯϘϧΛฦ͢͜ͱΛظ͢Δ ҾΛνΣοΫ͢Δ෦
ܕνΣοΫ ؆қతʹܕνΣοΫΛߦͳ͏αϯϓϧίʔυ string2symbol ͕จࣈྻΛҾʹͱͬͯγϯϘϧΛฦ͢͜ͱΛظ͢Δ ฦΓΛνΣοΫ͢Δ෦
ܕνΣοΫ ؆қతʹܕνΣοΫΛߦͳ͏αϯϓϧίʔυ string2symbol ͕จࣈྻΛҾʹͱͬͯγϯϘϧΛฦ͢͜ͱΛظ͢Δ ࣮ߦͯ͠ΈΔͱΤϥʔ͕ग़Δ
tspec gem ͜ͷΞΠσΞΛ gem Խͨ͠ͷ "GitHub", "tspec", https://github.com/siman-man/tspec
tspec gem ࣮ղઆ͔͚ͨͬͨ͠Ͳॻ͍ͨຊਓΘ͔Βͳ͍΄ͲΧΦεͩͬͨͷׂѪ "GitHub", "tspec", https://github.com/siman-man/tspec ?
ࢀߟαΠτ ɾhttp://www.atdot.net/~ko1/diary/201212.html#d12 [Ruby VM ΞυϕϯτΧϨϯμʔ #12 TracePoint ͷհ (1)] ɾhttp://www.atdot.net/~ko1/diary/201212.html#d13
[Ruby VM ΞυϕϯτΧϨϯμʔ #13 TracePoint ͷհ (2)] ɾhttp://www.atdot.net/~ko1/diary/201212.html#d14 [Ruby VM ΞυϕϯτΧϨϯμʔ #14 TracePoint ͷհ (3)] ɾ"ΫοΫύου։ൃऀϒϩά", "Ruby 2.5 ͷվળΛࣗຫ͍ͨ͠", http://techlife.cookpad.com/entry/2017/12/28/113839 ɾ"TracePointΫϥε", "ϓϩάϥϛϯάݴޠ Ruby ϦϑΝϨϯεϚχϡΞϧ", https://docs.ruby-lang.org/ja/latest/class/TracePoint.html
ྑ͍ TracePoint ϥΠϑΛ