Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"debug.gem" の利用体験・開発体験の向上

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Naoto Ono Naoto Ono
July 12, 2022
12

"debug.gem" の利用体験・開発体験の向上

Avatar for Naoto Ono

Naoto Ono

July 12, 2022
Tweet

Transcript

  1. 自己紹介 • 小野 直人(@ono-max) ◦ Software Engineer at 株式会社サイバーエージェント ▪

    Developer Productivity 室 • フィーチャーフラグ・A/Bテストプラットフォームの開発 ◦ Google Summer of Code 2021 “Tests for Debugger” ▪ Ruby 3.1 から導入された “debug.gem” のテストフレームワーク作成 ◦ 最近ネズミが家に出ました 🐭
  2. debug.gem • 笹田さん(@ko1)が開発したすごいデバッガ • ブレークポイント設定時の処理速度が速い • VS Code などの IDE

    サポート • Ruby 2.7 以上をサポート • ターミナルでの起動例 ◦ rdbg target.rb ◦ rdbg -c -- bin/rails
  3. デバッガとは • バグの発見や修正を支援するツール ◦ ある瞬間における変数 ◦ コードが実行される流れ • 基本機能 ◦

    ブレークポイント ◦ ステップイン ◦ ステップオーバー ◦ … コードリーディング にも便利!
  4. def a b end def b c end def c

    end ①メソッド a が 呼ばれる バックトレース
  5. def a b end def b c end def c

    end ①メソッド a が 呼ばれる バックトレース a メソッド a が積ま れる
  6. def a b end def b c end def c

    end ②メソッドbを 呼ぶ バックトレース a
  7. def a b end def b c end def c

    end バックトレース ③メソッド b が 呼ばれる a
  8. def a b end def b c end def c

    end バックトレース b ③メソッド b が 呼ばれる a メソッド b が積ま れる
  9. def a b end def b c end def c

    end バックトレース b a 現在 過去 今いる地点まで の呼び出し履歴
  10. def a b end def b c end def c

    end バックトレース b この行で実行が 停止 a 現在の状態
  11. class Node attr_accessor :value, :next def initialize val, _next @next

    = _next @value = val end end def linked_list list = nil 5.times{|n| node = Node.new n, list list = node } list end linked_list サイズ5の 線形リストを作る
  12. 目標 • Chrome DevTools でのデバッグを VS Code と同等のものへ • Chrome

    DevTools 特有の機能を用いたリッチな開発体験の実現
  13. クリックすることでネストされたものを表示 foo = { "a": [ { "a": 1 },

    { "b": 1 } ], "b": [ { "c": 1 }, { "d": 1 . . . クリックすることで値を 見れる 複雑なハッシュも見た い箇所だけ見ることが できる
  14. 評価 • Chrome DevTools でのデバッグ体験を VS Code と同等のものへ => 一部 Chrome

    DevTools の制約を除いて同等の体験を実現 • Chrome DevTools 特有の機能を用いたリッチな開発体験の実現 => スニペット機能、現在状態の変数の表示など独自機能を提供
  15. # Chrome DevTools { id: 13, method: "Debugger.setBreakpointByUrl", params: {

    lineNumber: 3, columnNumber: 0, condition: "" ... } # VS Code { seq: 12, command: "setBreakpoints", arguments: { source: { name: "target.rb", path: temp_file_path, sourceReference: 0 }, ... } req_add_breakpoint 3 抽象化 例外発生時に停止 低レベル • API が生のプロトコ ルとなる 高レベル • API が簡潔な メソッドになる
  16. 得られた成果 • 利用体験の向上 ◦ Chrome でのデバッグができるようになり VS Code を使わないユーザーにも リッチなデバッグ体験を提供

    ◦ Chrome DevTools への対応をしたデバッガの一つの参考例に • “debug.gem” の開発効率の向上 ◦ UI ツールとの通信部分のテストが可能に
  17. 引用・参考文献 • Chromium Blog. 「10 Years of Chrome DevTools」 https://blog.chromium.org/2018/09/10-years-of-chrome-devtools.html

    (参照2022-06-30) • 渋川よしき.「Real World HTTP 第2版」. 株式会社オライリー・ジャパン . 2021年, 496p • ◯×つくろーどっとコム. 「その1 デバッグの超基本「ステップ実行」」 http://marupeke296.com/DBG_No1_Step.html#:~:text=%E3%82%B9%E3%83%86%E3%83%83%E 3%83%97%E3%82%A4%E3%83%B3%E3%81%AF%E6%9C%80%E3%82%82%E3%82%B9%E3 %83%86%E3%83%83%E3%83%97,%E5%85%A5%E3%82%8B%E3%81%93%E3%81%A8%E3% 81%8C%E3%81%A7%E3%81%8D%E3%81%BE%E3%81%99%E3%80%82 (参照2022-07-09) • Debugging with GDB. 「スタックの検査」 https://www.asahi-net.or.jp/~wg5k-ickw/html/online/gdb-4.18/gdb_7.html (参照2022-07-09)