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
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
Can We Measure Developer Productivity?
ewolff
1
150
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
750
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
480
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
1k
OTelCol_TailSampling_and_SpanMetrics
gumamon
1
170
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
130
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
310
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The Language of Interfaces
destraynor
154
24k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
What's in a price? How to price your products and services
michaelherold
243
12k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
What's new in Ruby 2.0
geeforr
343
31k
The Invisible Side of Design
smashingmag
298
50k
Unsuck your backbone
ammeep
668
57k
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 ϥΠϑΛ