$30 off During Our Annual Pro Sale. View Details »

なんかトレースするはなし

 なんかトレースするはなし

NARUSE, Yui

July 02, 2016
Tweet

More Decks by NARUSE, Yui

Other Decks in Programming

Transcript

  1. ps -eFlL جຊฤ • -e: Select all processes. • -l:

    Long Format. The -y option is often useful with this. • -y Do not show flags; show rss in place of addr. • -F: Extra full format. See the -f option, which -F implies. • -f: When used with -L, the NLWP (number of threads) and LWP (thread ID) columns will be added • ར఺ • ಛݖ͕͍Βͳ͍ • ର৅ϓϩηεʹ෭࡞༻͕ແ͍
  2. PROC - PROCESS INFORMATION PSEUDO-FILESYSTEM procfs(5) • ͍Ζ͍ΖΘ͔ΔɻҰԡ͠͸ stat (30)

    kstkeip %lu The current EIP (instruction pointer). ࣮ߦதͷ໋ྩͷΞυϨε͸ 140308168160605 = 0x7f9c0a85b55d
  3. procfs • ͱ͍͏ͷΛ΍Δ΍ͭ • https://gist.github.com/nurse/0619b6af90df140508c2 • ࠷ۙͷUbuntuͷ৔߹ɺಉҰϢʔβʔͰ΋ಛݖ͕ඞཁ • gdbʹΞλονͰ͖ͳ͍ͱ͖
 ʹΧʔωϧ಺Ͱ͍ࢗͬͯ͞Δͱ͖


    ʹ͖͜͞͞Μ͕ѱ͍ͱ͖
 ͦΜͳͱ͖Ͱ΋৘ใ͕ಘΒΕΔͷ͕Α͍ • ΋ͪΖΜϢʔβʔϥϯυΛ࣮ߦதͰ΋Θ͔Δ • ΠϯετʔϧෆཁͳͷͰ͓٬͞Μͱ͔ʹࢼͯ͠΋Β͍΍͍͢
  4. • όοΫτϨʔε΋ݟ͍ͨ • ͦΜͳ΋ͷ͸ʢprocfsʹ͸ʣͳ͍ • perf_event_open(2) • sample_type=PERF_SAMPLE_CALLCHAINΛࢦఆ͢Ε͹औΕ Δؾ΋͢Δ……? •

    ͨͩ͠CͷελοΫτϨʔε͚ͩ • ptrace(2) • ϓϩηεʹγάφϧૹΔͷ͕ؾʹͳΔ • gcore(1)ͰίΞు͔ͤͯgdbͰͬ͘͡ΓΈΔͷ΋Α͍ • ͱ͔͔ͬΓͱͳΔγϯϘϧ͑͋͞Ε͹ɺʢRubyϨϕϧͷόο ΫτϨʔεͰ͋Ζ͏ͱʣͳΜͩͬͯΘ͔ΔͷͰ͕Μ͹͍ͬͯ͘