魅せるデバッグ技術

 魅せるデバッグ技術

iOSDC Reject Conference days2

0a86666ca90016b2a28289dda921b0d7?s=128

Toshihiro Morimoto

August 31, 2016
Tweet

Transcript

  1. 2016/08/31 iOSDC Reject Conference days2 @dealforest Toshihiro Morimoto ັͤΔσόοάٕज़

  2. ࣗݾ঺հ

  3. Works

  4. None
  5. (ͭд⊂)ŠƄŢŠƄŢ

  6. None
  7. ʢʀƅЧƅʣ …ʂʁ

  8. ొஃऀ͕ޙ൒Λ઎ΊΔͱ͍͏๫ڍw

  9. ັͤΔσόοάٕज़

  10. None
  11. ͯ͞ɺօ͞Μ ͜͏͍͏৔߹Ͳ͏͠·͔͢ʁʁ

  12. None
  13. None
  14. ౰વ͜Εʹؾ͍ͮͨҙࣝͷߴ͍ ͋ͳͨ͸σόοάΛ։࢝͠·͢

  15. ϩάΛ࢓ࠐΜͰ…

  16. ࠶ىಈʂ

  17. None
  18. (ͭд⊂)ŠƄŢŠƄŢ

  19. None
  20. ※ ຊਓͷڐՄ͸ಘ͍ͯ·͢

  21. Α͠ɺ࣍ʹ࠶ݱͨ͠Βௐ΂Α͏…

  22. ϓϦϯτσόοά͋Δ͋ΔͰ͢Ͷ

  23. ࢓ํͳ͍ͷͰ೴಺σόοά։࢝

  24. ݪҼީิ • େݩͷը૾͋Δʁ • ௨৴Τϥʔʁ • cache ͯͨ͠ը૾͕͓͔͍͠ʁ • SDWebImage,

    Kingfisher ͳͲͷ͍ͤʁ
  25. શવΘ͔Γ·ͤΜͶ

  26. ͦΜͳ࣌ͦ͜ LLDB ͷग़൪Ͱ͢

  27. LLDB ͳΒͦͷλΠϛϯάͰͷ ৘ใΛऔಘ͢Δ͜ͱ͕Ͱ͖·͢

  28. େݩͷը૾͋Δ? ϒϥ΢βͰ௚઀ͦͷ URL Λ։͍͍ͯͩ͘͞w

  29. ௨৴Τϥʔʁ ΤϥʔϋϯυϦϯάͯ͠ΔՕॴʹ Breakpoint Λઃఆ͢Δ ΤϥʔϋϯυϦϯά͍ͯ͠ͳ͍ͳΒɺϥΠϒϥϦͷதͰ ֘౰ՕॴΛؤுͬͯݟ͚͍ͭͯͩ͘͞ɻ (͔ͬͯɺ΍ͬͯͳ͍ਓͳΜ͍ͯͳ͍ͱࢥ͏͚Ͳ)

  30. cache ͯͨ͠ը૾͕͓͔͍͠ʁ (lldb) po let $URL = NSURL(string: “http://~”) (lldb)

    po let $request = NSURLRequest(URL: $URL) (lldb) po let $data = NSURLCache.sharedURLCache(). cachedResponseForRequest(request)!. data (lldb) po let $path = “/Users/dealforest/cache.png” (lldb) po $data.writeToFile($path, atomically: true)
  31. SDWebImage, Kingfisher ͳͲͷ͍ͤʁ // Kingfisher ͷ৔߹ (lldb) po let $URL

    = NSURL(string: “http://~”) (lldb) po let $resource = Resource(downloadURL: $URL) (lldb) po let $cache = KingfisherManager.sharedManager.cache // memory (lldb) po let $image = $cache.retrieveImageInMemoryCacheForKey($resource.cacheKey) // disk (lldb) po let $image = $cache.retrieveImageInDiskCacheForKey($resource.cacheKey) (lldb) po let $data = UIImagePNGRepresentation($image)! (lldb) po $data.writeToFile(<path>, atomically: true)
  32. ͍͔͕Ͱ͔͢ʁʁ

  33. গ͠͸ঢ়گ͕೺ѲͰ͖ͨ͸ͣͰ͢

  34. Ұ౓͚ͩͳΒ·ͩ͠΋ ͳΜͲ΋ಉ͜͡ͱ͢ΔͱͳΔͱ…

  35. ϥΠϒϥϦʹ͢Δͷ΋ͳ…

  36. ࢓ํͳ͍ ͦ͏͍͏Ϋϥε࡞Δ͔

  37. ଞͷϓϩδΣΫτͰ΋࢖͍͍ͨͳ

  38. ίϐϖ

  39. ͦ͏͢Δͱ ϓϩμΫτͱؔ܎͕ͳ͍ίʔυ͕ ૿͍͖͑ͯ·͢

  40. ͔͠΋ϓϩδΣΫτຖʹ มΘͬͯΓ͢Δͱ…

  41. Φϫλ ʘ(^o^)ʗ

  42. LLDB ͷ Plugin ʹ͢Ε͹͍͍Μͩʂ

  43. analyse_image // ΦϦδφϧը૾Λϒϥ΢βͰ։͖ // ֤ cache ͷը૾Λग़ྗ͠ Preview Ͱදࣔ͢ΔίϚϯυ (lldb)

    analyse_image “http://~” [original] browser open [request] ok [cache] ok -> “<path_to>/cache.png” [Kingfisher] memory ok -> “<path_to>/kingfisher_memory.png” [Kingfisher] disk ok -> “<path_to>/kingfisher_disk.png”
  44. Ͳ͏Ͱ͔͢ʁʁ ͜ΜͳͷϖΞϓϩͰ͞ΕͨΒ

  45. ͓͓͓͓͓͓͓ʂʂʂʂʂ Έ͍ͨʹͳͬͪΌ͍·ͤΜ͔ʁʁ

  46. ͳΓ·͢ΑͶʁʁ

  47. Ͷʁʁ

  48. LLDB ίϚϯυʹ͢ΔϝϦοτΛ ز͔ͭڍ͓͖͛ͯ·͢

  49. LLDB Plugin ʹ͢ΔϝϦοτ • σόοά࣌ʹ debug, release Ϗϧυ͕Ͳ͏͔͸ɹɹ ؔ܎ͳ͍ (#ifdef

    DEBUG ϚΫϩͷढ͍) • ϓϩδΣΫτ͕มΘͬͯ΋ಉ͡؀ڥͰσόοάͰ͖Δ • debug ༻ͷίʔυΛຒΊࠐΉඞཁ͕ͳ͍ • debug ͷҝʹ private method Λݺͼग़͍ͯ͠ΔͷΛ ϦϦʔεϏϧυʹؚΉ৺഑͕ͳ͍
  50. ͜Μͳ Plugin ͭ͘Ε͹ศརͰ͢ • ҰఆִؒͰදࣔ͞Ε͍ͯΔ view શͯʹରͯ͠ exerciseAmbiguityInLayout Λ࣮ߦ͢ΔίϚϯυɹɹ (ambigurous

    layout ରࡦ) • ࣮ػͷϑΝΠϧΛ slack ʹૹ৴͢ΔίϚϯυɹɹɹɹ https://gist.github.com/dealforest/702a848ba0a7a64b139985f5cad885f0 • ݱࡏͷ୺຤ͷঢ়گΛදࣔ͢ΔίϚϯυɹɹɹɹɹɹɹɹɹ free diskɺfree memory, ωοτϫʔΫ઀ଓઌ, ɹɹ OS όʔδϣϯͳͲ
  51. Ͳ͏Ͱ͢ʁʁ ΍ͬͯΈͨ͘ͳΓ·͔ͨ͠ʁʁ

  52. LLDB Plugin ͷ࡞Γํ͸ ͜ͷޙϒϩάʹॻ͘ͷͰ গʑ͓଴͍ͪͩ͘͞

  53. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠