Next: , Previous: , Up: Lispデバッガ   [Contents][Index]


19.1.10 デバッガの呼び出し

以下ではデバッガを呼び出すために使用される関数debugの完全な詳細を説明します。

Command: debug &rest debugger-args

This function enters the debugger. In interactive sessions, it switches to a buffer named *Backtrace* (or *Backtrace*<2> if it is the second recursive entry to the debugger, etc.), and fills it with information about the stack of Lisp function calls. It then enters a recursive edit, showing the backtrace buffer in Debugger mode. In batch mode (more generally, when noninteractive is non-nil, see batchモード), this function shows the Lisp backtrace on the standard error stream, and then kills Emacs, causing it to exit with a non-zero exit code (see Emacsのkill). Binding backtrace-on-error-noninteractive to nil suppresses the backtrace in batch mode, see below.

Debuggerモードのコマンドcdjrは再帰編集をexitする。その後、debugは以前のバッファーに戻って、debugを呼び出したものが何であれそこにリターンする。これは関数debugが呼び出し元にリターンできる唯一の方法である。

debugger-argsを使用すると、debug*Backtrace*の最上部に残りの引数を表示するしてユーザーがそれらを確認できる。以下で説明する場合を除いて、これはこれらの引数を使用する唯一の方法である。

しかしdebugへの1つ目の引数にたいする値は、特別な意味をもつ(これらの値は通常はdebugを呼び出すプログラマーではなく、Emacs内部でのみ使用される)。以下はこれら特別な値のテーブルである:

lambda

1つ目の引数がlambdaのなら、それはdebug-on-next-callが非nilのときに関数にエントリーしたことによってdebugが呼び出されたことを意味する。デバッガはバッファーのトップのテキスト行に‘Debugger entered--entering a function:’と表示する。

debug

1つ目の引数がdebugなら、それはエントリー時にデバッグされるようにセットされた関数にエントリーしたことにってdebugが呼び出されたことを意味する。デバッガはlambdaのときと同様、‘Debugger entered--entering a function:’を表示する。これはその関数のスタックフレームもマークするので、exit時にデバッガが呼び出される。

t

1つ目の引数がtなら、それはdebug-on-next-callが非nilのときに関数呼び出しの評価によってdebugが呼び出されたことを示す。デバッガはバッファーのトップの行に‘Debugger entered--beginning evaluation of function call form:’と表示する。

exit

1つ目の引数がexitのときは、exit時にデバッガを呼び出すよう以前にマークされたスタックフレームをexitしたことを示す。この場合はdebugに与えられた2つ目の引数がそのフレームからリターンされた値になる。デバッガはバッファーのトップの行に‘Debugger entered--returning value:’とリターンされた値を表示する。

error

1つ目の引数がerrorのときは、ハンドルされていないエラーまたはquitがシグナルされてデバッガにエンターした場合であり、デバッガは‘Debugger entered--Lisp error:’とその後にシグナルされたエラーとsignalへの引数を表示してそれを示す。たとえば、

(let ((debug-on-error t))
  (/ 1 0))

------ Buffer: *Backtrace* ------
Debugger entered--Lisp error: (arith-error)
  /(1 0)
...
------ Buffer: *Backtrace* ------

エラーがシグナルされた場合はおそらく変数debug-on-errorは非nilで、quitがシグナルされた場合はおそらく変数debug-on-quitは非nilである。

nil

明示的にデバッガにエンターしたいときは、debugger-argsの1つ目の引数にnilを使用する。残りのdebugger-argsはバッファーのトップの行にプリントされる。メッセージ — たとえばdebugが呼び出された条件を思い出すためのリマインダーとして — の表示にこの機能を使用できる。

Variable: backtrace-on-error-noninteractive

If this variable is non-nil, the default, entering the debugger in batch mode shows the backtrace of Lisp functions calls. Binding the variable to the nil value suppresses the backtrace and shows only the error message.

This page has generated for branch:master, commit:762705fb24fd90db318f2e51c1e762452d26f7e2 to check Japanese translation.