|
| 1 | +## これは何? |
| 2 | +RubyKaigi2010 向け[[解説資料動画パート1|RubyKaigi2010-emacs-rdebug.ogv]]の概要の和訳です |
| 3 | +The following is a rough transcript of the [[first part of a short video presentation|RubyKaigi2010-emacs-rdebug.ogv]] at Ruby Kaigi 2010 |
| 4 | + |
| 5 | +## Transcript |
| 6 | +Emacs 上で動く Ruby デバッガはいくつも存在します。その中から、私の独断と偏見でベストだと思うものをいくつか取り上げます。 |
| 7 | +There are a number of Emacs debugger interfaces for Ruby. I'll mention couple of them that in my biased opinion are the best. |
| 8 | + |
| 9 | +最初に、ruby-debug を紹介します。私はこれが最も洗練されていると思います。利用するためには、Gentoo Linux を使っている人以外は、ソースからインストールする必要があるでしょう。インストール手順は[[ここ|http://bashdb.sf.net/ruby-debug/rdebug-emacs.html#Installation]]に書かれています。 |
| 10 | +The first works only for the debugger ruby-debug. I think it is the most sophisticated. Unless you are using a Gentoo Linux distribution, you will have to install this from the source. Installation instructions are [[here|http://bashdb.sf.net/ruby-debug/rdebug-emacs.html#Installation]]. |
| 11 | + |
| 12 | +インストールが終わったら、`M-x load-library rdebug` でロードします。 |
| 13 | +To load the Emacs code after the Emacs package has been installed: `M-x load-library rdebug` |
| 14 | + |
| 15 | +"rdebug" というコマンドが使えるようになっています。ここからは、サンプルプログラムを一からデバッグしていきます。まずは `M-x rdebug` から。 |
| 16 | +And now I have a command called "rdebug". I will use that to debug a sample program from the beginning. `M-x rdebug` |
| 17 | + |
| 18 | +Debian ディストリビューションには、別の「rdebug」Emacs Lisp が存在します。パッケージ名「emacs-goodies」のものがそうです。プロンプトに `--emacs` と表示されていれば、正しいものを使っています。 |
| 19 | +There is another Emacs rdebug Lisp command that comes in the Debian distribution under the package name *emacs-goodies*. You know you have the right one if you see `--emacs` in the prompt. |
| 20 | + |
| 21 | +`M-x rdebug --emacs 3 gcd.rb 3 5` |
| 22 | + |
| 23 | +画面上段には、デバッガのコマンドラインとローカル変数の一覧が表示されています。中段にはソースコードと出力が。ソースコード枠の端には、矢印が表示されています。これは、今から実行しようとしている文を指しています。 |
| 24 | +The top-most panel of windows is split between the debugger command line and local variables. The middle panel is split between the source code and output. There is an arrow in the fringe area of the source-code window to show you the statement you are about to run. |
| 25 | + |
| 26 | +ここで Debugger メニューを見てみましょう。`[Stack of windows]` や `[Rocky II]` など、違った枠レイアウトが選べることが分かります。 |
| 27 | +Check out the Debugger menu and the Window Layout section of that. You will see alternative window formats such as `[Stack of windows]` or `[Rocky II]` |
| 28 | + |
| 29 | +`frame 0` で画面をリフレッシュします。 |
| 30 | +To refresh the display `frame 0` |
| 31 | + |
| 32 | +1ステップ進めてみましょう。ソースコード枠とコールスタック枠が更新されるでしょう。現時点では gcd.rb の4行目にいます。 |
| 33 | +Let me step a statement and you will see the location in both the source code and the call stack windows updated. Right now we are at line 4 in file gcd.rb |
| 34 | + |
| 35 | +`step` |
| 36 | + |
| 37 | +コールスタック枠は、いま18行目にいるとの表示に変わり、ソースコート枠の矢印は現在位置に移動しました。 |
| 38 | +Note that the call-stack windows show that we are now at line 18 and the source code fringe arrow has been updated. |
| 39 | + |
| 40 | +"next" コマンドを使って現在行をステップオーバーしてみましょう。現状だと nil になっている変数 a と b の値が更新されます。 |
| 41 | +Let me step over the entire line shown here using the command "next" and you will see that the values of "a" and "b" updated. Right now the values are nil. |
| 42 | + |
| 43 | +コマンドライン枠でコマンドを使う代わりに、ソースコード枠の方で操作することもできます。単一キーストロークだけでデバッガコマンドを実行できるマイナーモードがあります。rdebug-short-key-mode というのがそれです。実際にやってみましょう。 |
| 44 | +Instead of running commands in a commmand-line window, you can run commands inside the source-code window. There is minor mode that allows single key-strokes to run debugger commands. This is called rdebug-short-key-mode. Let me show that. |
| 45 | + |
| 46 | +`M-x rdebug-short-key-mode` |
| 47 | + |
| 48 | +"ShortKeys" という表示が出たことと、ファイルのバッファがリードオンリーになっているのがポイントです。 |
| 49 | +Notice the "ShortKeys" indicator and also notice the file is now read only. [points to %%]. |
| 50 | + |
| 51 | +この状態でスペースキーを叩くとステップ実行できます。一番下には実際に実行されたコマンドが表示されています。 |
| 52 | +Now when I hit the space bar, I step a statement. And down in the bottom message area I see the debugger command that was run. |
| 53 | + |
| 54 | +コールスタック枠には2行表示されています。一つはいま実行している gcd メソッドの、もう一つは gcd を呼び出している箇所のものです。 |
| 55 | +Notice the call-stack window now has two entries: an entry to reflect that I am in the gcd method and an entry for the place where I called gcd. |
| 56 | + |
| 57 | +ブレークポイントを置くには、b をタイプします。デフォルト状態では有効になりますが、t をタイプすると無効になります。再び t をタイプすると有効に戻ります。 |
| 58 | +To set a breakpoint I type "b". Breakpoints are enabled by default but to toggle the breakpoint from enabled to disabled I type "t". Type "t" again and the breakpoint is enabled. |
0 commit comments