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
780
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
98
railsdm2019.pdf
siman
2
790
Qiita の記事の typo を 1ヶ月間直し続けた話
siman
0
610
Other Decks in Technology
See All in Technology
生成AI×財務経理:PoCで挑むSlack AI Bot開発と現場巻き込みのリアル
pohdccoe
1
810
20250304_赤煉瓦倉庫_DeepSeek_Deep_Dive
hiouchiy
2
130
サイト信頼性エンジニアリングとAmazon Web Services / SRE and AWS
ymotongpoo
7
1.8k
2/18 Making Security Scale: メルカリが考えるセキュリティ戦略 - Coincheck x LayerX x Mercari
jsonf
0
260
EDRの検知の仕組みと検知回避について
chayakonanaika
12
5.3k
OPENLOGI Company Profile
hr01
0
60k
AI Agent時代なのでAWSのLLMs.txtが欲しい!
watany
3
370
EMConf JP 2025 懇親会LT / EMConf JP 2025 social gathering
sugamasao
2
210
大規模アジャイルフレームワークから学ぶエンジニアマネジメントの本質
staka121
PRO
3
1.6k
20250307_エンジニアじゃないけどAzureはじめてみた
ponponmikankan
2
140
AIエージェント入門
minorun365
PRO
33
20k
JAWS DAYS 2025 アーキテクチャ道場 事前説明会 / JAWS DAYS 2025 briefing document
naospon
0
2.8k
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Why Our Code Smells
bkeepers
PRO
336
57k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Building Your Own Lightsaber
phodgson
104
6.2k
Raft: Consensus for Rubyists
vanstee
137
6.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.5k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
21
2.5k
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
Gamification - CAS2011
davidbonilla
80
5.2k
Code Review Best Practice
trishagee
67
18k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
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 ϥΠϑΛ