LoginSignup
5
4

More than 5 years have passed since last update.

RubyMotionでのデバッグ

Last updated at Posted at 2014-12-16

RubyMotionのデバッガー

  • LLVM のデバッガ LLDB をベースにしたもの

  • RubyMotion アプリのプロセスへの接続と内部の調査ができるようしたもの

  • かなり低レベル

デバッガを起動する方法

simulator タスクで作業する場合

$ rake simulater debug=1

rake の device タスクを実行する場合

$ rake device debug=1

アプリケーションが実行される前にGDBコマンドを実行したい場合

$ rake debug=1 no-continue=1

この後デバッギングの設定を行ったりできる

(lldb) breakpoint set --file hello_view.rb --line 10

アプリケーション実行時に実行したいコマンドをファイルで保持

デバッガはプロジェクトのルートディレクトリ内のdebugger_cmdsというファイルを参照する

$ echo "breakpoint set --file hello_view.rb --line 10" > debugger_cmds
$ rake debug=1  

デバッガ起動時のコマンド

現在のデバッグ環境で設定されているブレークポイントの確認

(lldb) breakpoint list

バックトレースをたどる

(lldb) thread backtrace

バックトレースの特定のフレームへ移動する

# デフォルトではトップフレーム(#0)
(lldb) frame select 2

実行中のすべてのバックトレースを表示する

(lldb) thread backtrace all

スレッドの切り替え

(lldb) thread select 2

指定されたオブジェクトに対してinspectメッセージを送りその値を返す

(lldb) print-ruby-object self
(lldb) pro box #print-ruby-objectのショートカット

ローカル変数のリストを表示する

(lldb) frame variable

ローカル変数の調査

(lldb) pro text

オブジェクトのインスタンス変数表示

(lldb) print-ruby-ivar "@window"
(lldb) pri self "@window"

rubyのソースコードレベルで次の行へ移動する

(lldb) next

ブレークポイントへ到達するまで実行を再開

(lldb) continue

デバッガの終了

(lldb)exit #もしくはquit

参照

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4