5.38.0

NAME

perldebug - Perl debugging

perldebug - Perl のデバッグ

説明

First of all, have you tried using use strict; and use warnings;?

まず最初に、もう use strict;use warnings; は 使ってみましたか?

If you're new to the Perl debugger, you may prefer to read perldebtut, which is a tutorial introduction to the debugger.

もし Perl デバッガに慣れていないなら、デバッガに関するチュートリアルである perldebtut を読んだ方がいいかもしれません。

If you're looking for the nitty gritty details of how the debugger is implemented, you may prefer to read perldebguts.

デバッガがどのように 実装されているか に関する詳細を探している場合は、 perldebguts を読んだ方が良いでしょう。

For in-depth technical usage details, see perl5db.pl, the documentation of the debugger itself.

掘り下げた技術的な使用法の詳細については、デバッガ自体の文書である perl5db.pl を参照してください。

The Perl Debugger

If you invoke Perl with the -d switch, your script runs under the Perl source debugger. This works like an interactive Perl environment, prompting for debugger commands that let you examine source code, set breakpoints, get stack backtraces, change the values of variables, etc. This is so convenient that you often fire up the debugger all by itself just to test out Perl constructs interactively to see what they do. For example:

Perl を -d スイッチを付けて起動すれば、スクリプトは Perl ソースデバッガ 上で実行されることになります。 これは対話的な Perl 環境のように動作し、 ソースコードの表示、ブレークポイントの設定、スタックのバックトレース、 変数の値の変更、などを実行するデバッガコマンドを入力できます。 これはとても便利なので、単にやりたいことを対話的に試すために デバッガを起動するようになるでしょう。 例えば:

    $ perl -d -e 42

In Perl, the debugger is not a separate program the way it usually is in the typical compiled environment. Instead, the -d flag tells the compiler to insert source information into the parse trees it's about to hand off to the interpreter. That means your code must first compile correctly for the debugger to work on it. Then when the interpreter starts up, it preloads a special Perl library file containing the debugger.

しかし、Perl デバッガは典型的なコンパイルされた環境の様に独立した プログラムではありません。 その代わりに、 -d フラグによって、コンパイラがインタプリタに渡すパース木にソース情報を 埋め込むようにしています。これは、ソースがデバッガ上で動作できるためには、 一度正常にコンパイルできないといけないということです。 それからインタプリタが起動され、デバッガを含む 特別な Perl ライブラリをロードします。

The program will halt right before the first run-time executable statement (but see below regarding compile-time statements) and ask you to enter a debugger command. Contrary to popular expectations, whenever the debugger halts and shows you a line of code, it always displays the line it's about to execute, rather than the one it has just executed.

プログラムは、最初の実行時実行文の直前で停止し (ただし、以下コンパイル時実行文については後述します)、以下に示すいずれかの コマンドが入力されるのを待ちます。 よくある期待とは逆に、 デバッガが停止してある行のコードを表示しているときは、 直前に実行した行ではなく、常に今から実行する行を表示します。

Any command not recognized by the debugger is directly executed (eval'd) as Perl code in the current package. (The debugger uses the DB package for keeping its own state information.)

デバッガが認識できないコマンドは現在のパッケージ内で Perl のコードとして 実行(eval)されます。 (デバッガは自分自身の状態を保存するために DB パッケージを使います。)

Note that the said eval is bound by an implicit scope. As a result any newly introduced lexical variable or any modified capture buffer content is lost after the eval. The debugger is a nice environment to learn Perl, but if you interactively experiment using material which should be in the same scope, stuff it in one line.

eval は暗黙のスコープで区切られていることに注意してください。 結果として、新しく導入されたレキシカル変数や変更された捕捉バッファの内容は eval の後失われます。 デバッガは Perl を学ぶよい環境ですが、もし同じスコープ内であるべき ものを使って対話的に実験したい場合は、それを 1 行に書いてください。

For any text entered at the debugger prompt, leading and trailing whitespace is first stripped before further processing. If a debugger command coincides with some function in your own program, merely precede the function with something that doesn't look like a debugger command, such as a leading ; or perhaps a +, or by wrapping it with parentheses or braces.

デバッガコマンドとして入力された文字列は、まず先頭と末尾の 空白が切り詰められます。 デバッガコマンドがプログラムの関数名と一致する場合、 関数名の前に ;+ のような、デバッガコマンドに見えない文字を 付け加えるか、括弧でくくってください。

デバッガを呼び出す

There are several ways to call the debugger:

デバッガを呼び出すにはいくつかの方法があります:

perl -d program_name

On the given program identified by program_name.

program_name で識別されるプログラムに対して。

perl -d -e 0

Interactively supply an arbitrary expression using -e.

-e を使って指定された任意の expression を対話的に。

perl -d:ptkdb program_name

Debug a given program via the Devel::ptkdb GUI.

Devel::Ptkdb GUI 経由で与えられたプログラムをデバッグする。

perl -dt threaded_program_name

Debug a given program using threads (experimental).

スレッドを使っているプログラムをデバッグする(実験的機能)。

If Perl is called with the -d switch, the variable $^P will hold a true value. This is useful if you need to know if your code is running under the debugger:

Perl が -d オプション付きで呼び出された場合、 変数 $^P は真の値を保持します。 コードがデバッガ上で実行されているかどうかを知る必要がある場合に有用です:

    if ( $^P ) {
        # running under the debugger
    }

See "$^P" in perlvar for more information on the variable.

この変数に関するさらなる情報については "$^P" in perlvar を参照してください。

デバッガコマンド

The interactive debugger understands the following commands:

対話式のデバッガは以下のコマンドを理解します:

h

Prints out a summary help message

サマリヘルプメッセージを表示します。

h [command]

Prints out a help message for the given debugger command.

指定されたコマンドの説明を表示します。

h h

The special argument of h h produces the entire help page, which is quite long.

h h という特別なコマンドは、かなり長い、ヘルプ全体を表示します。

If the output of the h h command (or any command, for that matter) scrolls past your screen, precede the command with a leading pipe symbol so that it's run through your pager, as in

h h コマンド(や他のコマンドでも)の出力で画面がスクロールしてしまう場合、 以下のようにコマンドの前にパイプ記号をつけるとページャーを呼び出します:

    DB> |h h

You may change the pager which is used via o pager=... command.

使用されるページャーは O pager=... コマンドで変更できます。

p expr

Same as print {$DB::OUT} expr in the current package. In particular, because this is just Perl's own print function, this means that nested data structures and objects are not dumped, unlike with the x command.

現在のパッケージでの print {$DB::OUT} expr と同じです。 特に、これは Perl 自身の print 関数なので、 x コマンドと違って、ネストしたデータ構造やオブジェクトはダンプしません。

The DB::OUT filehandle is opened to /dev/tty, regardless of where STDOUT may be redirected to.

STDOUT がどこにリダイレクトされていても、 ファイルハンドル DB::OUT/dev/tty に対して オープンされています。

x [maxdepth] expr

Evaluates its expression in list context and dumps out the result in a pretty-printed fashion. Nested data structures are printed out recursively, unlike the real print function in Perl. When dumping hashes, you'll probably prefer 'x \%h' rather than 'x %h'. See Dumpvalue if you'd like to do this yourself.

式をリストコンテキストで評価し、結果を多少読みやすい形で表示します。 ネストしたデータは再帰的に表示します; これは Perl の実際の print 関数とは 異なります。 ハッシュをダンプするとき、おそらく 'x %h' より 'x \%h' を好むでしょう。 これを自分自身で行いたい場合は Dumpvalue を参照して下さい。

The output format is governed by multiple options described under "Configurable Options".

出力フォーマットは "Configurable Options"" in " に記された 様々なオプションの影響を受けます。

If the maxdepth is included, it must be a numeral N; the value is dumped only N levels deep, as if the dumpDepth option had been temporarily set to N.

maxdepth が指定されている場合、それは数値 N でなければなりません; dumpDepth オプションが一時的に N に設定されたかのように、 値は N レベルの深さでだけダンプされます。

V [pkg [vars]]

Display all (or some) variables in package (defaulting to main) using a data pretty-printer (hashes show their keys and values so you see what's what, control characters are made printable, etc.). Make sure you don't put the type specifier (like $) there, just the symbol names, like this:

package (デフォルトは main) 内のすべて (または、一部) の 変数 (variable) をデータプリティプリンタを使って表示します (ハッシュは何が何か解るように、key と value を表示し、 コントロール文字は表示できる形にします)。 以下に示すように、symbol は名前だけを示し、($ などの) 型識別子を 付けないようにしてください:

    V DB filename line

Use ~pattern and !pattern for positive and negative regexes.

正と逆の正規表現のためには ~pattern!pattern を使ってください。

This is similar to calling the x command on each applicable var.

これは有効な変数のそれぞれについて x を呼び出すのと似ています。

X [vars]

Same as V currentpackage [vars].

V 現在のパッケージ [vars] と同じです。

y [level [vars]]

Display all (or some) lexical variables (mnemonic: mY variables) in the current scope or level scopes higher. You can limit the variables that you see with vars which works exactly as it does for the V and X commands. Requires the PadWalker module version 0.08 or higher; will warn if this isn't installed. Output is pretty-printed in the same style as for V and the format is controlled by the same options.

現在のスコープや、level だけ高いスコープの全て(またはいくつか)の レキシカル変数を表示します(記憶法: mY 変数)。 VX コマンドと全く同じように、vars を制定することで 表示される変数を制限できます。 バージョン 0.08 以降の PadWalker モジュールが必要です; もしインストールされていなければ警告されます。 出力は V コマンドと同じスタイルにフォーマットされ、 このフォーマットは同じオプションで制御されます。

T

Produce a stack backtrace. See below for details on its output.

スタックのバックトレースを行います。出力についての詳細は後述します。

s [expr]

Single step. Executes until the beginning of another statement, descending into subroutine calls. If an expression is supplied that includes function calls, it too will be single-stepped.

シングルステップ実行します。 サブルーチンをたどりながら、別の実行文の先頭に到達するまで実行します。 関数呼び出しを含む式が与えられた場合、これもシングルステップ実行します。

n [expr]

Next. Executes over subroutine calls, until the beginning of the next statement. If an expression is supplied that includes function calls, those functions will be executed with stops before each statement.

ネクスト。次の実行文の先頭に到達するまで、サブルーチンにまたがって実行します。 関数呼び出しを含む式が与えられた場合、 各行毎に停止しながら関数を実行します。

r

Continue until the return from the current subroutine. Dump the return value if the PrintRet option is set (default).

現在のサブルーチンから戻るまで実行します。 PrintRet がセットされていれば(デフォルトではセットされています) 返り値をダンプします。

<CR>

Repeat last n or s command.

最後の n または s を繰り返します。

c [line|sub]

Continue, optionally inserting a one-time-only breakpoint at the specified line or subroutine.

続きを実行します; オプションとして、1 回限りのブレークポイントを指定された 行またはサブルーチンに設定します。

l

List next window of lines.

次の 1 画面分をリスト表示します。

l min+incr

List incr+1 lines starting at min.

min から incr+1 行をリスト表示します。

l min-max

List lines min through max. l - is synonymous to -.

min 行から max 行をリスト表示します。 l -- と同じです。

l line

List a single line.

指定行をリスト表示します。

l subname

List first window of lines from subroutine. subname may be a variable that contains a code reference.

サブルーチンの最初の一画面分をリスト表示します。 subname は コードリファレンスが入った変数でも構いません。

-

List previous window of lines.

前の 1 画面分をリスト表示します。

v [line]

View a few lines of code around the current line.

指定行付近の(数行のコードをリスト表示します。

.

Return the internal debugger pointer to the line last executed, and print out that line.

最後に実行した行への内部デバッガポインタを返し、 その行を表示します。

f filename

Switch to viewing a different file or eval statement. If filename is not a full pathname found in the values of %INC, it is considered a regex.

異なるファイルまたは eval 行に表示を切り替えます。 もし filename が %INC にあるフルパス名でなければ、 正規表現として扱われます。

evaled strings (when accessible) are considered to be filenames: f (eval 7) and f eval 7\b access the body of the 7th evaled string (in the order of execution). The bodies of the currently executed eval and of evaled strings that define subroutines are saved and thus accessible.

eval した文字列は(アクセス可能なら)ファイル名として扱われます: f (eval 7)f eval 7\b は (実行した順で) 7 番目に eval した 文字列の中身にアクセスします。 現在実行した eval の中身と、サブルーチンを定義する eval した 中身は保存されるので、アクセス可能です。

/pattern/

Search forwards for pattern (a Perl regex); final / is optional. The search is case-insensitive by default.

pattern を用いて Perl 正規表現による前方検索を行います; 最後の / は なくてもかまいません。 デフォルトでは検索は大文字小文字を区別しません。

?pattern?

Search backwards for pattern; final ? is optional. The search is case-insensitive by default.

pattern を用いて後方検索を行います; 最後の ? はなくてもかまいません。 デフォルトでは検索は大文字小文字を区別しません。

L [abw]

List (default all) actions, breakpoints and watch expressions

ブレークポイント、アクション、ウォッチ式を (デフォルトは全て)リストアップします。

S [[!]regex]

List subroutine names [not] matching the regex.

regex に一致する(または一致しない)サブルーチン名をリストアップします。

t [n]

Toggle trace mode (see also the AutoTrace option). Optional argument is the maximum number of levels to trace below the current one; anything deeper than that will be silent.

トレースモードの on/off を切り替えます (AutoTrace オプションも 参照して下さい)。 オプションの引数は現在のもの以下でトレースする最大レベル数です; これよりも深いものは沈黙します。

t [n] expr

Trace through execution of expr. Optional first argument is the maximum number of levels to trace below the current one; anything deeper than that will be silent. See "Frame Listing Output Examples" in perldebguts for examples.

expr の実行をトレースします。 オプションの引数は現在のもの以下でトレースする最大レベル数です; これよりも深いものは沈黙します。 例については "Frame Listing Output Examples" in perldebguts を 参照して下さい。

b

Sets breakpoint on current line

現在の位置にブレークポイントを設定します。

b [line] [condition]

Set a breakpoint before the given line. If a condition is specified, it's evaluated each time the statement is reached: a breakpoint is taken only if the condition is true. Breakpoints may only be set on lines that begin an executable statement. Conditions don't use if:

与えられた行の直前にブレークポイントを設定します。 condition が指定されると、その文にさしかかる度に評価されます: condition が 真となったときにだけブレークポイントが働きます。 ブレークポイントは、実行可能な文で始まる行にだけ、設定できます。 condition には if を使いません:

    b 237 $x > 30
    b 237 ++$count237 < 11
    b 33 /pattern/i

If the line number is ., sets a breakpoint on the current line:

行番号が . なら、現在行にブレークポイントを設定します:

    b . $n > 100
b [file]:[line] [condition]

Set a breakpoint before the given line in a (possibly different) file. If a condition is specified, it's evaluated each time the statement is reached: a breakpoint is taken only if the condition is true. Breakpoints may only be set on lines that begin an executable statement. Conditions don't use if:

ブレークポイントを(おそらくは異なった)ファイルの指定された行に設定します。 condition が指定されると、その文にさしかかる度に評価されます: condition が 真となったときにだけブレークポイントが働きます。 ブレークポイントは、実行可能な文で始まる行にだけ、設定できます。 condition には if を使いません:

    b lib/MyModule.pm:237 $x > 30
    b /usr/lib/perl5/site_perl/CGI.pm:100 ++$count100 < 11
b subname [condition]

Set a breakpoint before the first line of the named subroutine. subname may be a variable containing a code reference (in this case condition is not supported).

サブルーチンの最初の実行可能文にブレークポイントを設定します。 subname は コードリファレンスが入った変数でも構いません (この場合は condition は非対応です)。

b postpone subname [condition]

Set a breakpoint at first line of subroutine after it is compiled.

コンパイル後、サブルーチンの最初の行にブレークポイントをセットします。

b load filename

Set a breakpoint before the first executed line of the filename, which should be a full pathname found amongst the %INC values.

filename の最初に実行される行の手前にブレークポイントをセットします; これは %INC の値に含まれるフルパス名であるべきです。

b compile subname

Sets a breakpoint before the first statement executed after the specified subroutine is compiled.

指定されたサブルーチンがコンパイルされた後、最初に実行される文の手前に ブレークポイントをセットします。

B line

Delete a breakpoint from the specified line.

line で指定されたブレークポイントを削除します。

B *

Delete all installed breakpoints.

すべてのブレークポイントを削除します。

disable [file]:[line]

Disable the breakpoint so it won't stop the execution of the program. Breakpoints are enabled by default and can be re-enabled using the enable command.

ブレークポイントを向こうにして、プログラムの実行を止めないようにします。 ブレークポイントはデフォルトで有効で、enable コマンドを使って 再有効化できます。

disable [line]

Disable the breakpoint so it won't stop the execution of the program. Breakpoints are enabled by default and can be re-enabled using the enable command.

ブレークポイントを向こうにして、プログラムの実行を止めないようにします。 ブレークポイントはデフォルトで有効で、enable コマンドを使って 再有効化できます。

This is done for a breakpoint in the current file.

これは現在のファイルのブレークポイントに対して行われます。

enable [file]:[line]

Enable the breakpoint so it will stop the execution of the program.

ブレークポイントを有効にして、プログラムの実行を止めるようにします。

enable [line]

Enable the breakpoint so it will stop the execution of the program.

ブレークポイントを有効にして、プログラムの実行を止めるようにします。

This is done for a breakpoint in the current file.

これは現在のファイルのブレークポイントに対して行われます。

a [line] command

Set an action to be done before the line is executed. If line is omitted, set an action on the line about to be executed. The sequence of steps taken by the debugger is

その行を実行する前に行うアクションを設定します。 line が省略されると、いままさに実行しようとしていた行に アクションを設定します。 デバッガが実行する処理の順番は以下の通りです。

  1. check for a breakpoint at this line
  2. print the line if necessary (tracing)
  3. do any actions associated with that line
  4. prompt user if at a breakpoint or in single-step
  5. evaluate line
  1. この行のブレークポイントをチェックします
  2. 必要なら行を表示します(トレース)
  3. この行に結び付けられたアクションを実行します
  4. ブレークポイントやシングルステップの場合はユーザーに確認します
  5. 行を評価します

For example, this will print out $foo every time line 53 is passed:

例えば、以下のコードは 53 行を通過する毎に $foo を表示します。

    a 53 print "DB FOUND $foo\n"
A line

Delete an action from the specified line.

指定された行に設定されたアクションを削除します。

A *

Delete all installed actions.

設定されたすべてのアクションを削除します。

w expr

Add a global watch-expression. Whenever a watched global changes the debugger will stop and display the old and new values.

グローバルなウォッチ式を追加します。 グローバルな変更が行われたときは、デバッガは停止して新旧の値を表示します。

W expr

Delete watch-expression

ウォッチ式を削除します。

W *

Delete all watch-expressions.

全てのウォッチ式を削除します。

o

Display all options.

全てのオプションを表示します。

o booloption ...

Set each listed Boolean option to the value 1.

リストされた各真偽値オプションの値を 1 に設定します。

o anyoption? ...

Print out the value of one or more options.

1 つ、あるいは複数のオプションの値を表示します。

o option=value ...

Set the value of one or more options. If the value has internal whitespace, it should be quoted. For example, you could set o pager="less -MQeicsNfr" to call less with those specific options. You may use either single or double quotes, but if you do, you must escape any embedded instances of same sort of quote you began with, as well as any escaping any escapes that immediately precede that quote but which are not meant to escape the quote itself. In other words, you follow single-quoting rules irrespective of the quote; eg: o option='this isn\'t bad' or o option="She said, \"Isn't it?\"".

一つまたは複数のオプションをセットします。 値自身に空白を含む場合、クォートする必要があります。 例えば、less をオプション付きで呼び出す場合は o pager="less -MQeicsNfr" のようにします。 シングルクォートとダブルクォートのどちらでも使えますが、クォートする場合は、 クォート文字と同じ文字はエスケープする必要があります; そしてエスケープ文字自身もエスケープして、クォート文字を エスケープしているのではないことを示す必要があります。 言い換えると、クォートに関わりなく、シングルクォートルールに従います; 例えば: o option='this isn\'t bad'o option="She said, \"Isn't it?\""

For historical reasons, the =value is optional, but defaults to 1 only where it is safe to do so--that is, mostly for Boolean options. It is always better to assign a specific value using =. The option can be abbreviated, but for clarity probably should not be. Several options can be set together. See "Configurable Options" for a list of these.

歴史的な理由により、=value は省略可能ですが、そうするのが安全な場合にのみ デフォルトは 1 です -- これは、ほとんどの場合ブール値オプションです。 = を使って指定した値を代入する方が常によいです。 option は短縮できますが、明確化のためにはそうしない方がいいでしょう。 いくつかのオプションは互いにセットできます。 それらの一覧については "Configurable Options"" in " を参照してください。

< ?

List out all pre-prompt Perl command actions.

プロンプト表示前に実行するアクションを全て表示します。

< [ command ]

Set an action (Perl command) to happen before every debugger prompt. A multi-line command may be entered by backslashing the newlines.

デバッガがプロンプトを出す直前に、毎回実行するアクション (Perl のコマンド)を設定します。 複数行の command は、バックスラッシュと改行で書くことができます。

< *

Delete all pre-prompt Perl command actions.

プロンプト表示前に実行するアクションを全て削除します。

<< command

Add an action (Perl command) to happen before every debugger prompt. A multi-line command may be entered by backwhacking the newlines.

デバッガがプロンプトを出す直前に、毎回実行するアクション (Perl のコマンド)を追加します。 複数行の command は、バックスラッシュと改行で書くことができます。

> ?

List out post-prompt Perl command actions.

プロンプト表示後に実行するアクションを全て表示します。

> command

Set an action (Perl command) to happen after the prompt when you've just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines (we bet you couldn't have guessed this by now).

スクリプトの実行に戻るコマンドを入力した時に、デバッガが プロンプトを出した後で、毎回実行するアクション(Perl のコマンド)を設定します。 複数行の command は、バックスラッシュと改行で書くことができます (きっとあなたは今までこのことを知らなかったはずです)。

> *

Delete all post-prompt Perl command actions.

プロンプト表示後に実行するアクションを全て削除します。

>> command

Adds an action (Perl command) to happen after the prompt when you've just given a command to return to executing the script. A multi-line command may be entered by backslashing the newlines.

スクリプトの実行に戻るコマンドを入力した時に、デバッガが プロンプトを出した後で、毎回実行するアクション(Perl のコマンド)を追加します。 複数行の command は、バックスラッシュと改行で書くことができます。

{ ?

List out pre-prompt debugger commands.

プロンプト表示前に実行するデバッガコマンドを表示します。

{ [ command ]

Set an action (debugger command) to happen before every debugger prompt. A multi-line command may be entered in the customary fashion.

デバッガがプロンプトを出す前に、毎回実行するアクション(デバッガの コマンド)を設定します。 複数行の command は、いつもの方法で書くことができます 警告 もし command がないと、全てのアクションが消えてしまいます!

Because this command is in some senses new, a warning is issued if you appear to have accidentally entered a block instead. If that's what you mean to do, write it as with ;{ ... } or even do { ... }.

このコマンドはある意味新しいので、もし代わりに間違ってブロックを 入力したように見えるときには、警告が出ます。 本当に奏したい場合は、;{ ... } か、いっそ do { ... } と 書いてください。

{ *

Delete all pre-prompt debugger commands.

プロンプト前に実行するデバッガコマンドを全て削除します。

{{ command

Add an action (debugger command) to happen before every debugger prompt. A multi-line command may be entered, if you can guess how: see above.

毎回デバッガプロンプトを表示する前に実行するアクション(デバッガコマンド)を 追加します。予測可能な方法な方法で複数行コマンドも登録できます: 上記を参照してください。

! number

Redo a previous command (defaults to the previous command).

以前のコマンドを再実行します(number が省略されると、直前のコマンドを 実行します)。

! -number

Redo number'th previous command.

指定数値分前のコマンドを実行します。

! pattern

Redo last command that started with pattern. See o recallCommand, too.

pattern で始まるうち、最も最近に実行されたコマンドを 再実行します。 O recallCommand も参照して下さい。

!! cmd

Run cmd in a subprocess (reads from DB::IN, writes to DB::OUT) See o shellBang, also. Note that the user's current shell (well, their $ENV{SHELL} variable) will be used, which can interfere with proper interpretation of exit status or signal and coredump information.

cmd をサブプロセスとして実行します(DB::IN から読み込み、DB::OUT に 書き出します)。 O shellBang も参照してください。 ユーザーの現在のシェル(つまり、 $ENV{SHELL} 変数)が使われるので、 終了コードの適切な解釈やシグナルとコアダンプの情報が妨害されるかもしれない ことに注意してください。

source file

Read and execute debugger commands from file. file may itself contain source commands.

デバッガコマンドを file から読み込んで実行します。 file 自身に source コマンドを含んでいても構いません。

H -number

Display last n commands. Only commands longer than one character are listed. If number is omitted, list them all.

最近の指定数値分のコマンドを表示します。 2 文字以上のコマンドのみが表示されます。 number が省略されると、全てを表示します。

q or ^D

Quit. ("quit" doesn't work for this, unless you've made an alias) This is the only supported way to exit the debugger, though typing exit twice might work.

デバッガを終了します。 (エイリアスを設定しない限り、"quit" はこの目的には使えません) これはデバッガを終了する唯一の方法ですが、exit を 2 回 入力しても動作します。

Set the inhibit_exit option to 0 if you want to be able to step off the end the script. You may also need to set $finished to 0 if you want to step through global destruction.

スクリプトの最後にステップ実行できるようにしたい場合は、 inhibit_exit オプションに 0 を設定してください。 グローバルなデストラクタを実行してステップ実行したい場合は、 $finished に 0 を設定する必要があります。

R

Restart the debugger by exec()ing a new session. We try to maintain your history across this, but internal settings and command-line options may be lost.

新しいセッションを exec() することでデバッガを再起動します。 履歴は残そうと努力しますが、内部設定やコマンドラインオプションは 失われるかもしれません。

The following setting are currently preserved: history, breakpoints, actions, debugger options, and the Perl command-line options -w, -I, and -e.

今のところ、以下の設定は保存されます: 履歴、ブレークポイント、アクション、 デバッガオプション、Perl コマンドラインオプション -w, -I, -e

|dbcmd

Run the debugger command, piping DB::OUT into your current pager.

デバッガコマンドを実行し、DB::OUT をパイプであなたの現在のページャと繋ぎます。

||dbcmd

Same as |dbcmd but DB::OUT is temporarily selected as well.

|dbcmd と同様ですが、 DB::OUT は一時的に select で 選択されているものになります。

= [alias value]

Define a command alias, like

以下のようにコマンドエイリアスを定義する:

    = quit q

or list current aliases.

または現在のエイリアスの一覧を表示します。

command

Execute command as a Perl statement. A trailing semicolon will be supplied. If the Perl statement would otherwise be confused for a Perl debugger, use a leading semicolon, too.

command を Perl の文として実行します。文末のセミコロンはなくてもかまいません。 Perl の文が Perl デバッガにとって紛らわしい場合は 先頭にセミコロンをつけてください。

m expr

List which methods may be called on the result of the evaluated expression. The expression may evaluated to a reference to a blessed object, or to a package name.

評価した表現の結果が呼び出されたメソッドを一覧表示します。 表現は bless されたオブジェクトへのリファレンスか、パッケージ名として 評価されます。

M

Display all loaded modules and their versions.

読み込まれたモジュールとバージョンを全て表示します。

man [manpage]

Despite its name, this calls your system's default documentation viewer on the given page, or on the viewer itself if manpage is omitted. If that viewer is man, the current Config information is used to invoke man using the proper MANPATH or -M manpath option. Failed lookups of the form XXX that match known manpages of the form perlXXX will be retried. This lets you type man debug or man op from the debugger.

その名前にも関わらず、これは与えられたページ(manpage が省略された 場合はビューワ自身)に対してシステムのデフォルトのドキュメントビューワを 呼び出します。 ビューワが man の場合、適切な MANPATH や -M manpath オプションを使って man を起動するために、現在の Config 情報が 使われます。 XXX の形で一致する man ページの検索に失敗した場合、 perlXXX の形のものを再検索します。 これにより、デバッガから man debugman op と タイプできるようになります。

On systems traditionally bereft of a usable man command, the debugger invokes perldoc. Occasionally this determination is incorrect due to recalcitrant vendors or rather more felicitously, to enterprising users. If you fall into either category, just manually set the $DB::doccmd variable to whatever viewer to view the Perl documentation on your system. This may be set in an rc file, or through direct assignment. We're still waiting for a working example of something along the lines of:

伝統的に利用可能な man コマンドを奪われたシステムでは、デバッガは< perldoc を起動します。 反抗的なベンダーや、より適切には、積極的なユーザーによって、この判断は 正しくありません。 もしあなたがどちらかの分類に当てはまってしまうなら、Perl のドキュメントを 表示するためにどのビューワを使うかを、手動で $DB::doccmd 変数に セットしてください。 これは rc ファイルででも、直接の代入ででもセットできます。 私たちは以下のような感じで、実際に動作する例を待っています:

    $DB::doccmd = 'netscape -remote http://something.here/';

設定可能なオプション

The debugger has numerous options settable using the o command, either interactively or from the environment or an rc file. The file is named ./.perldb or ~/.perldb under Unix with /dev/tty, perldb.ini otherwise.

デバッガには O コマンドで設定できるさまざまなオプションがあります; これは対話的、環境変数、rc ファイルで設定できます。 ファイル名は Unix では /dev/tty./.perldb または ~/.perldb、それ以外では perldb.ini です。

recallCommand, ShellBang

The characters used to recall a command or spawn a shell. By default, both are set to !, which is unfortunate.

再呼び出しコマンドとシェル起動に使われる文字です。 デフォルトでは、残念ながら、両方とも ! にセットされています。

pager

Program to use for output of pager-piped commands (those beginning with a | character.) By default, $ENV{PAGER} will be used. Because the debugger uses your current terminal characteristics for bold and underlining, if the chosen pager does not pass escape sequences through unchanged, the output of some debugger commands will not be readable when sent through the pager.

ページャにパイプされるコマンド(文字 | で始まるもの)の出力に 使われるプログラム。 デフォルトでは、$ENV{PAGER} が使われます。 デバッガは強調と下線に関して現在の端末設定を使うので、もし選択した ページャがエスケープシーケンスを変更せずに通過させられない場合、 一部のデバッガコマンドの出力は、ページャに送られると読めなくなるでしょう。

tkRunning

Run Tk while prompting (with ReadLine).

プロンプトで (ReadLine と共に) Tk を実行します。

signalLevel, warnLevel, dieLevel

Level of verbosity. By default, the debugger leaves your exceptions and warnings alone, because altering them can break correctly running programs. It will attempt to print a message when uncaught INT, BUS, or SEGV signals arrive. (But see the mention of signals in "BUGS" below.)

詳細さのレベル。 デフォルトでは、デバッガは例外と警告を放っておきます; これを変更すると、プログラムが正しく動かなくなることがあるからです。 捕捉されていない INT, BUS, SEGV シグナルがあると、メッセージを 表示しようとします。 (しかし、以下の BUGS のシグナルに関する注意を参照してください。)

To disable this default safe mode, set these values to something higher than 0. At a level of 1, you get backtraces upon receiving any kind of warning (this is often annoying) or exception (this is often valuable). Unfortunately, the debugger cannot discern fatal exceptions from non-fatal ones. If dieLevel is even 1, then your non-fatal exceptions are also traced and unceremoniously altered if they came from eval'ed strings or from any kind of eval within modules you're attempting to load. If dieLevel is 2, the debugger doesn't care where they came from: It usurps your exception handler and prints out a trace, then modifies all exceptions with its own embellishments. This may perhaps be useful for some tracing purposes, but tends to hopelessly destroy any program that takes its exception handling seriously.

このデフォルトのセーフモードを無効にするには、これらの値を 0 以上に セットしてください。 レベル 1 では、あらゆる種類の警告(これはしばしばうんざりさせるものです)や 例外(これはしばしば価値があります)を受信した時にバックトレースを得ます。 残念ながら、デバッガは致命的な例外と致命的でない例外を識別できません。 dieLevel は 1 であっても、致命的でない例外もトレースされ、 それが eval された 文字列からか、読み込もうとしたモジュール内の あらゆる種類の eval からのものであるなら、突然置き換えられます。 dieLevel が 2 なら、デバッガは例外の出所を気にしません: 例外ハンドラを横取りしてトレースを表示し、それから全ての例外を自身の装飾で 修正します。 これはある種のトレースの目的にはおそらく有用ですが、 例外をまじめに扱っているプログラムをどうしようもなく破壊してしまう傾向が あります。

AutoTrace

Trace mode (similar to t command, but can be put into PERLDB_OPTS).

トレースモード(t コマンドと同様ですが、PERLDB_OPTS に書けます)。

LineInfo

File or pipe to print line number info to. If it is a pipe (say, |visual_perl_db), then a short message is used. This is the mechanism used to interact with a client editor or visual debugger, such as the special vi or emacs hooks, or the ddd graphical debugger.

行番号情報を記録するファイルまたはパイプ。 これが (|visual_perl_db のように) パイプの場合、短い文章が使われます。 これは、特別な viemacs のフックや、ddd グラフィカル デバッガのようなクライアントエディタやビジュアルデバッガと相互作用するために 使われる機構です。

inhibit_exit

If 0, allows stepping off the end of the script.

0 だと、スクリプトの最後で プログラムを終了する ことを認めます。

PrintRet

Print return value after r command if set (default).

設定されると(デフォルト)、r コマンドの後に返り値を表示します。

ornaments

Affects screen appearance of the command line (see Term::ReadLine). There is currently no way to disable these, which can render some output illegible on some displays, or with some pagers. This is considered a bug.

コマンドラインの画面への表示に影響を与えます(Term::ReadLine を 参照してください)。 今のところ、これを無効にする方法はありません; これにより、ディスプレイやページャーによっては判読できない出力を 行うことがあります。 これはバグと考えられています。

frame

Affects the printing of messages upon entry and exit from subroutines. If frame & 2 is false, messages are printed on entry only. (Printing on exit might be useful if interspersed with other messages.)

サブルーチンへの出入り時のメッセージ表示に影響を与えます。 frame & 2 が偽なら、サブルーチンに入る時にのみメッセージを出力します。 (出るときのメッセージは、他のメッセージがまき散らされているときには 有用でしょう。)

If frame & 4, arguments to functions are printed, plus context and caller info. If frame & 8, overloaded stringify and tied FETCH is enabled on the printed arguments. If frame & 16, the return value from the subroutine is printed.

frame & 4 の場合、関数の引数に加えて、コンテキストと呼び出し元の 情報を表示します。 frame & 8 の場合、引数の表示にオーバーロードされた 文字列化tie した FETCH が有効になります。 frame & 16 の場合、サブルーチンからの返り値が表示されます。

The length at which the argument list is truncated is governed by the next option:

引数リストが切り詰められた時の長さは次のオプションの管轄となります:

maxTraceLen

Length to truncate the argument list when the frame option's bit 4 is set.

frame オプションの bit 4 がセットされている時の引数リストを切り詰める 長さ。

windowSize

Change the size of code list window (default is 10 lines).

コードリストウィンドウの大きさを変更します(デフォルトは 10 行です)。

The following options affect what happens with V, X, and x commands:

以下のオプションは V, X, x コマンドに影響を与えます。

arrayDepth, hashDepth

Print only first N elements ('' for all).

最初の N 要素だけを表示します('' を指定すると全て表示します)。

dumpDepth

Limit recursion depth to N levels when dumping structures. Negative values are interpreted as infinity. Default: infinity.

構造をダンプするときに再帰の深さを N レベルに制限します。 負数を指定すると無限として解釈されます。 デフォルト: 無限。

compactDump, veryCompact

Change the style of array and hash output. If compactDump, short array may be printed on one line.

配列とハッシュの出力スタイルを変更します。 compactDump の場合は、短い配列は 1 行で表示します。

globPrint

Whether to print contents of globs.

グロブの内容を表示するかどうかです。

DumpDBFiles

Dump arrays holding debugged files.

デバッグしていているファイルが保持している配列をダンプします。

DumpPackages

Dump symbol tables of packages.

パッケージのシンボルテーブルをダンプします。

DumpReused

Dump contents of "reused" addresses.

「再利用された」アドレスの内容をダンプします。

quote, HighBit, undefPrint

Change the style of string dump. The default value for quote is auto; one can enable double-quotish or single-quotish format by setting it to " or ', respectively. By default, characters with their high bit set are printed verbatim.

文字列ダンプのスタイルを変更します。 quote のデフォルトは auto です; "' にセットすることでダブルクォート風やシングルクォート風に できます。 デフォルトでは、最上位ビットがセットされている文字はそのまま表示されます。

UsageOnly

Rudimentary per-package memory usage dump. Calculates total size of strings found in variables in the package. This does not include lexicals in a module's file scope, or lost in closures.

基本的なパッケージ単位のメモリ使用量ダンプ。 パッケージ内の変数で見つかった文字列のサイズの合計を計算します。 モジュールのファイルスコープ内のレキシカルや、クロージャ内で 失われたものは含まれません。

HistFile

The path of the file from which the history (assuming a usable Term::ReadLine backend) will be read on the debugger's startup, and to which it will be saved on shutdown (for persistence across sessions). Similar in concept to Bash's .bash_history file.

デバッガの起動時に読み込まれ、(セッションをまたいで永続させるために)終了時に 保管されるヒストリ (Term::ReadLine バックエンドが利用可能であることを 仮定しています) のファイルのパス。 Bash の .bash_history ファイルと同じ考え方です。

HistSize

The count of the saved lines in the history (assuming HistFile above).

ヒストリに保管される行数 (上述の HistFile を仮定します)。

After the rc file is read, the debugger reads the $ENV{PERLDB_OPTS} environment variable and parses this as the remainder of a "O ..." line as one might enter at the debugger prompt. You may place the initialization options TTY, noTTY, ReadLine, and NonStop there.

rc ファイルが読み込まれた後、デバッガは $ENV{PERLDB_OPTS} 環境変数を 読み込み、デバッガのプロンプトから "O ..." として入力されたかのように パースします。 初期化オプション TTY, noTTY, ReadLine, NonStop も ここで設定できます。

If your rc file contains:

rc ファイルに以下のように書くと:

  parse_options("NonStop=1 LineInfo=db.out AutoTrace");

then your script will run without human intervention, putting trace information into the file db.out. (If you interrupt it, you'd better reset LineInfo to /dev/tty if you expect to see anything.)

スクリプトは人間の介入なしに実行され、トレース情報を db.out ファイルに出力します。 (中断して、何も表示されない場合は、LineInfo/dev/tty に リセットしたほうがよいでしょう。)

TTY

The TTY to use for debugging I/O.

デバッグ I/O として TTY を使います。

noTTY

If set, the debugger goes into NonStop mode and will not connect to a TTY. If interrupted (or if control goes to the debugger via explicit setting of $DB::signal or $DB::single from the Perl script), it connects to a TTY specified in the TTY option at startup, or to a tty found at runtime using the Term::Rendezvous module of your choice.

セットすると、デバッガは NonStop モードとなり、TTY と接続されません。 もし中断された(または Perl スクリプトから明示的に $DB::signal や $DB::single をセットすることによってデバッガに制御が移った)場合、 起動時に TTY オプションで指定された TTY か、実行時に Term::Rendezvous モジュールで選択された TTY に接続されます。

This module should implement a method named new that returns an object with two methods: IN and OUT. These should return filehandles to use for debugging input and output correspondingly. The new method should inspect an argument containing the value of $ENV{PERLDB_NOTTY} at startup, or "$ENV{HOME}/.perldbtty$$" otherwise. This file is not inspected for proper ownership, so security hazards are theoretically possible.

このモジュールは、2 つのメソッド INOUT をもつオブジェクトを 返すメソッド new を実装する必要があります。 これらはそれぞれ、デバッグ入力と出力のためのファイルハンドルを 返すようにします。 new メソッドは起動時に $ENV{PERLDB_NOTTY} の値を含んでいる 引数を検査し、さもなければ "$ENV{HOME}/.perldbtty$$" となります。 このファイルは適切な所有権について検査されないので、 理論的にはセキュリティの問題が起こり得ます。

ReadLine

If false, readline support in the debugger is disabled in order to debug applications that themselves use ReadLine.

偽だと、デバッグするアプリケーション自身が ReadLine を使うために、 readline 対応を無効にします。

NonStop

If set, the debugger goes into non-interactive mode until interrupted, or programmatically by setting $DB::signal or $DB::single.

設定されると、デバッガは中断されるか、プログラム的に $DB::signal か $DB::single に設定されるまで、非対話的モードとなります。

Here's an example of using the $ENV{PERLDB_OPTS} variable:

以下に $ENV{PERLDB_OPTS} 変数を使った例を示します:

    $ PERLDB_OPTS="NonStop frame=2" perl -d myprogram

That will run the script myprogram without human intervention, printing out the call tree with entry and exit points. Note that NonStop=1 frame=2 is equivalent to N f=2, and that originally, options could be uniquely abbreviated by the first letter (modulo the Dump* options). It is nevertheless recommended that you always spell them out in full for legibility and future compatibility.

これは、人間の関与なしでスクリプト myprogram を実行し、進入と終了の ポイントの呼び出し木を表示します。 NonStop=1 frame=2N f=2 と等価で、もともとオプションは最初の文字 (Dump* オプションを法として) に省略できます。 それでもやはり、読みやすさと将来の互換性のために、常にフルスペルを書くことが 推奨されます。

Other examples include

もう一つの例としては:

    $ PERLDB_OPTS="NonStop LineInfo=listing frame=2" perl -d myprogram

which runs script non-interactively, printing info on each entry into a subroutine and each executed line into the file named listing. (If you interrupt it, you would better reset LineInfo to something "interactive"!)

とするとスクリプトは非対話的に実行され、サブルーチンへの進入と実行行を listing という名前のファイルに記録します。 (中断すると、何か「対話的」にするために LineInfo をリセットする方が 良いでしょう!)

Other examples include (using standard shell syntax to show environment variable settings):

(環境変数設定を表示する標準シェル構文を使った)もう一つの例としては:

  $ ( PERLDB_OPTS="NonStop frame=1 AutoTrace LineInfo=tperl.out"
      perl -d myprogram )

which may be useful for debugging a program that uses Term::ReadLine itself. Do not forget to detach your shell from the TTY in the window that corresponds to /dev/ttyXX, say, by issuing a command like

これは Term::ReadLine 地震を使っているプログラムをデバッグするのに 便利です。 以下のようなコマンドを使って、使用中のシェルを、/dev/ttyXX に対応する ウィンドウの TTY からデタッチすることを忘れないで下さい:

  $ sleep 1000000

詳細については "Debugger Internals" in perldebguts を参照してください。

デバッガの入出力

Prompt

The debugger prompt is something like

デバッガのプロンプトは以下のようだったり:

    DB<8>

or even

あるいは以下のようだったりします:

    DB<<17>>

where that number is the command number, and which you'd use to access with the built-in csh-like history mechanism. For example, !17 would repeat command number 17. The depth of the angle brackets indicates the nesting depth of the debugger. You could get more than one set of brackets, for example, if you'd already at a breakpoint and then printed the result of a function call that itself has a breakpoint, or you step into an expression via s/n/t expression command.

ここで数値はコマンド番号で、組み込みの csh 風履歴機構を使って アクセスするのに使います。 例えば、!17 はコマンド番号 17 を再実行します。 不等号の深さはデバッガのネストの深さを示します。 例えば、既にブレークポイントにいて、それ自身にもブレークポイントを 含む関数呼び出しの結果を表示させたり、s/n/t expression コマンドを 使って式をステップ実行したりした時に複数の不等号の組を見ることがあります。

Multiline commands

If you want to enter a multi-line command, such as a subroutine definition with several statements or a format, escape the newline that would normally end the debugger command with a backslash. Here's an example:

複数の文からなるサブルーチン定義やフォーマットといった、複数行の コマンドを入力したい場合は、通常はデバッガコマンドを終了させる改行を バックスラッシュでエスケープしてください。 以下は例です:

      DB<1> for (1..4) {         \
      cont:     print "ok\n";   \
      cont: }
      ok
      ok
      ok
      ok

Note that this business of escaping a newline is specific to interactive commands typed into the debugger.

この、改行をエスケープする問題は、対話的にデバッガに入力されたコマンドに 特有であることに注意してください。

Stack backtrace

Here's an example of what a stack backtrace via T command might look like:

これは、T コマンドによって表示されるスタックバックトレースの 例です:

 $ = main::infested called from file 'Ambulation.pm' line 10
 @ = Ambulation::legs(1, 2, 3, 4) called from file 'camel_flea'
                                                          line 7
 $ = main::pests('bactrian', 4) called from file 'camel_flea'
                                                          line 4

The left-hand character up there indicates the context in which the function was called, with $ and @ meaning scalar or list contexts respectively, and . meaning void context (which is actually a sort of scalar context). The display above says that you were in the function main::infested when you ran the stack dump, and that it was called in scalar context from line 10 of the file Ambulation.pm, but without any arguments at all, meaning it was called as &infested. The next stack frame shows that the function Ambulation::legs was called in list context from the camel_flea file with four arguments. The last stack frame shows that main::pests was called in scalar context, also from camel_flea, but from line 4.

上記の左側の文字は関数が呼び出されたコンテキストを示しています; $@ はそれぞれスカラコンテキストとリストコンテキストを意味し、 . は無効コンテキスト(実際のところはスカラコンテキストのようなもの)を 意味します。 上記の表示は、スタックダンプを実行したときに main::infested にいて、 これはファイル Ambulation.pm の 10 行目から、スカラコンテキストで 引数なしで呼び出されています; つまり &infested のようにして 呼び出されています。 次のスタックフレームは、関数 Ambulation::legscamel_flea から リストコンテキストで 4 つの引数と共に呼び出されています。 最後のスタックフレームは、main::pests が、同じファイル camel_flea の 4 行目からスカラコンテキストで呼び出されています。

If you execute the T command from inside an active use statement, the backtrace will contain both a require frame and an eval frame.

有効な use 文の中から T コマンドを実行すると、バックとレースには require フレームと eval フレームの両方が含まれます。

Line Listing Format

This shows the sorts of output the l command can produce:

これは l コマンドの出力を示しています:

   DB<<13>> l
 101:        @i{@i} = ();
 102:b       @isa{@i,$pack} = ()
 103             if(exists $i{$prevpack} || exists $isa{$pack});
 104     }
 105
 106     next
 107==>      if(exists $isa{$pack});
 108
 109:a   if ($extra-- > 0) {
 110:        %isa = ($pack,1);

Breakable lines are marked with :. Lines with breakpoints are marked by b and those with actions by a. The line that's about to be executed is marked by ==>.

ブレーク可能な行には : が付いています。 ブレークポイントのある行には b が、アクションがある行には a があります。 今から実行しようとしている行には ==> が付いています。

Please be aware that code in debugger listings may not look the same as your original source code. Line directives and external source filters can alter the code before Perl sees it, causing code to move from its original positions or take on entirely different forms.

デバッガで表示されるコードは、元のソースコードと同じように見えるとは 限らないことに注意してください。 行指示子と外部ソースフィルタが、Perl がコードを見る前にコードを 変更することがあり、それによってコードが元の位置から移動したり、 完全に異なる形になったりします。

Frame listing

When the frame option is set, the debugger would print entered (and optionally exited) subroutines in different styles. See perldebguts for incredibly long examples of these.

frame オプションが設定されると、デバッガはサブルーチンに入ったとき (および出たときもオプションで)違ったスタイルで表示します。 これらの非常に長い例については perldebguts を参照してください。

コンパイル時に実行される文のデバッグ

If you have compile-time executable statements (such as code within BEGIN, UNITCHECK and CHECK blocks or use statements), these will not be stopped by debugger, although requires and INIT blocks will, and compile-time statements can be traced with the AutoTrace option set in PERLDB_OPTS). From your own Perl code, however, you can transfer control back to the debugger using the following statement, which is harmless if the debugger is not running:

コンパイル時に実行される文 (BEGIN, UNITCHECK, CHECK のブロック内のコードや use 文) があれば、それらはデバッガによって止めることができません; require と INIT ブロックは可能です; また、コンパイル時実行文は PERLDB_OPTSAutoTrace オプションを設定することでトレースできます。 しかし、以下のような文を自分で Perl コードに含めれば、 デバッガに制御を渡すことができます; この文は、デバッガを 起動していないときには、何もしません:

    $DB::single = 1;

If you set $DB::single to 2, it's equivalent to having just typed the n command, whereas a value of 1 means the s command. The $DB::trace variable should be set to 1 to simulate having typed the t command.

$DB::single に 2 をセットすると、nコマンドをタイプしたのと 等価になります; 1 を設定すると s コマンドとなります。 $DB::trace 変数は t コマンドをタイプした状態をシミュレートするために 1 にセットするべきです。

Another way to debug compile-time code is to start the debugger, set a breakpoint on the load of some module:

コンパイル時に実行されるコードをデバッグするもう一つの方法は、 モジュールの load にブレークポイントを設定して:

    DB<7> b load f:/perllib/lib/Carp.pm
  Will stop on load of 'f:/perllib/lib/Carp.pm'.

and then restart the debugger using the R command (if possible). One can use b compile subname for the same purpose.

(可能なら) R コマンドを使ってデバッガを再起動することです。 b compile subname も同じ目的に使えます。

デバッガのカスタマイズ

The debugger probably contains enough configuration hooks that you won't ever have to modify it yourself. You may change the behaviour of the debugger from within the debugger using its o command, from the command line via the PERLDB_OPTS environment variable, and from customization files.

デバッガにはおそらくあなたが自分で修正する必要があるとは思わないような ところまで含んだ設定フックがあります。 デバッガの振る舞いは、デバッガ内で o コマンドを使って変更できます; これは PERLDB_OPT 環境変数経由でコマンドラインからか、設定ファイルから 変更できます。

You can do some customization by setting up a .perldb file, which contains initialization code. For instance, you could make aliases like these (the last one is one people expect to be there):

初期化コードを入れたファイル .perldb を設定することでも、 いくらかのカスタマイズができます。 たとえば、以下のようなエイリアスが行えます (最後のものは、 人々があると思っているものです):

    $DB::alias{'len'}  = 's/^len(.*)/p length($1)/';
    $DB::alias{'stop'} = 's/^stop (at|in)/b/';
    $DB::alias{'ps'}   = 's/^ps\b/p scalar /';
    $DB::alias{'quit'} = 's/^quit(\s*)/exit/';

You can change options from .perldb by using calls like this one;

.perldb のオプションを、以下のような呼び出しによって変更できます:

    parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=2");

The code is executed in the package DB. Note that .perldb is processed before processing PERLDB_OPTS. If .perldb defines the subroutine afterinit, that function is called after debugger initialization ends. .perldb may be contained in the current directory, or in the home directory. Because this file is sourced in by Perl and may contain arbitrary commands, for security reasons, it must be owned by the superuser or the current user, and writable by no one but its owner.

コードは DB パッケージで実行されます。 .perldbPERLDB_OPTS の前に処理されることに注意してください。 .perldbafterinit サブルーチンが定義されていると、この関数は デバッガの初期化終了後に呼び出されます。 .perldb はカレントディレクトリかホームディレクトリに置くことができます。 このファイルは Perl によって実行され、任意のコマンドを含めることが できるので、セキュリティ上の理由から、スーパーユーザーが現在のユーザーに よって所有され、所有者以外には書込み禁止になっていなければなりません。

You can mock TTY input to debugger by adding arbitrary commands to @DB::typeahead. For example, your .perldb file might contain:

@DB::typeahead に任意のコマンドを追加することで、デバッガへの TTY 入力を 模倣できます。 例えば、あなたの .perldb ファイルに以下のように書くと:

    sub afterinit { push @DB::typeahead, "b 4", "b 6"; }

Which would attempt to set breakpoints on lines 4 and 6 immediately after debugger initialization. Note that @DB::typeahead is not a supported interface and is subject to change in future releases.

デバッガ初期化の直後に 4 行目と 6 行目にブレークポイントを 設定しようとします。 @DB::typeahead はサポートしているインターフェースではなく、将来の リリースでは変更されることがあることに注意してください。

If you want to modify the debugger, copy perl5db.pl from the Perl library to another name and hack it to your heart's content. You'll then want to set your PERL5DB environment variable to say something like this:

デバッガを変更したい場合には、perl5db.pl を Perl ライブラリから 別の名前にコピーし、修正してください。それから 環境変数 PERL5DB には、以下のように設定する必要があるでしょう:

    BEGIN { require "myperl5db.pl" }

As a last resort, you could also use PERL5DB to customize the debugger by directly setting internal variables or calling debugger functions.

最後の手段として、 PERL5DB を、直接内部変数を設定したり デバッガ関数を呼び出すことでデバッガをカスタマイズすることもできます。

Note that any variables and functions that are not documented in this document (or in perldebguts) are considered for internal use only, and as such are subject to change without notice.

このドキュメント(や perldebguts)に記述されていない変数や 関数は内部使用専用として扱われ、予告なく変更されることがあります。

readline 対応 / デバッガのヒストリ

As shipped, the only command-line history supplied is a simplistic one that checks for leading exclamation points. However, if you install the Term::ReadKey and Term::ReadLine modules from CPAN (such as Term::ReadLine::Gnu, Term::ReadLine::Perl, ...) you will have full editing capabilities much like those GNU readline(3) provides. Look for these in the modules/by-module/Term directory on CPAN. These do not support normal vi command-line editing, however.

出荷時の状態では、コマンドライン履歴参照機能として提供されるのは、 エクスクラメーションマークを付けることによる単純なものだけです。 しかし、(Term::ReadLine::Gnu, Term::ReadLine::Perl, ... のように) CPAN から Term::ReadKeyTerm::ReadLine のモジュールを インストールすることで、GNU readline(3) が提供するような 完全な編集機能が使えるようになります。 これらは CPAN の modules/by-module/Term ディレクトリにあります。 しかし、これらは通常の vi コマンドライン編集は対応していません。

A rudimentary command-line completion is also available, including lexical variables in the current scope if the PadWalker module is installed.

基本的なパッケージ単位のメモリ使用量ダンプ; PadWalker モジュールが インストールされているなら現在のスコープのレキシカル変数も含みます。

Without Readline support you may see the symbols "^[[A", "^[[C", "^[[B", "^[[D"", "^H", ... when using the arrow keys and/or the backspace key.

Readline 対応なしでは、矢印キーやバックスペースキーを使うと "^[[A", "^[[C", "^[[B", "^[[D"", "^H" のような表示を見るかもしれません。

デバッグのためのエディタ対応

If you have the GNU's version of emacs installed on your system, it can interact with the Perl debugger to provide an integrated software development environment reminiscent of its interactions with C debuggers.

GNU 版の emacs がシステムにインストールされている場合は、 C デバッガとの連携を連想させるような、Perl デバッガとの統合 ソフトウェア開発環境を提供します。

Recent versions of Emacs come with a start file for making emacs act like a syntax-directed editor that understands (some of) Perl's syntax. See perlfaq3.

最近のバージョンの Emacs には emacs を Perl の文法(の一部)を解釈する文法指向の エディタとして振舞わせるためのスタートファイルを同梱しています。 perlfaq3 を参照してください。

Users of vi should also look into vim and gvim, the mousey and windy version, for coloring of Perl keywords.

vi ユーザーは、Perl のキーワードを色付けする、マウスとウィンドウ対応の vimgvim を調べてみてください。

Note that only perl can truly parse Perl, so all such CASE tools fall somewhat short of the mark, especially if you don't program your Perl as a C programmer might.

perl のみが完全に Perl をパースできるので、これら全ての CASE ツールには 足りないところがあることに注意してください; 特に C プログラマーが書くような Perl プログラムを書いていない場合はそうです。

Perl プロファイラ

If you wish to supply an alternative debugger for Perl to run, invoke your script with a colon and a package argument given to the -d flag. Perl's alternative debuggers include a Perl profiler, Devel::NYTProf, which is available separately as a CPAN distribution. To profile your Perl program in the file mycode.pl, just type:

Perl の実行に代替デバッガを使いたい場合は、-d オプションに コロンとパッケージからなる引数を付けてスクリプトを起動してください。 Perl 用代替デバッガは Perl プロファイラを含む Devel::DProf で、CPAN 配布として別に利用可能です。 ファイル mycode.pl にある Perl プログラムをプロファイリングしたい 場合、以下のようにします:

    $ perl -d:NYTProf mycode.pl

When the script terminates the profiler will create a database of the profile information that you can turn into reports using the profiler's tools. See <perlperf> for details.

スクリプトが終了すると、プロファイラはプロファイラのツールを使ってレポートに 変換出来るプロファイル情報のデータベースを作成します。 詳しくは perlperf を参照してください。

正規表現のデバッグ

use re 'debug' enables you to see the gory details of how the Perl regular expression engine works. In order to understand this typically voluminous output, one must not only have some idea about how regular expression matching works in general, but also know how Perl's regular expressions are internally compiled into an automaton. These matters are explored in some detail in "Debugging Regular Expressions" in perldebguts.

use re 'debug' を指定すると、Perl 正規表現エンジンがどのように 動作するかの詳細を見ることができます。 この、典型的には大量の出力を理解するためには、 一般的に正規表現マッチがどのように行われるかだけでなく、 Perl の正規表現が内部的にどのようにオートマトンにコンパイルされるかを 知らなければなりません。 これらの事柄は詳細は "Debugging Regular Expressions" in perldebguts にあります。

メモリ使用のデバッグ

Perl contains internal support for reporting its own memory usage, but this is a fairly advanced concept that requires some understanding of how memory allocation works. See "Debugging Perl Memory Usage" in perldebguts for the details.

Perl には自身のメモリ使用状況を報告するための内部機能がありますが、 しかしこれはかなり上級の概念で、メモリ割り当てがどのように行われるかに ついての理解が必要となります。 詳細については "Debugging Perl Memory Usage" in perldebguts を参照して下さい。

SEE ALSO

You do have use strict and use warnings enabled, don't you?

use strictuse warnings は有効にしていますよね?

perldebtut, perldebguts, perl5db.pl, re, DB, Devel::DProf, dprofpp, Dumpvalue, perlrun.

When debugging a script that uses #! and is thus normally found in $PATH, the -S option causes perl to search $PATH for it, so you don't have to type the path or which $scriptname.

#! を使っているので普通は $PATH に見つかるスクリプトをデバッグするとき、 -S オプションを付けると perl は $PATH からスクリプトを探すので、 パスや which $scriptname をタイプする必要がなくなります。

  $ perl -Sd foo.pl

バグ

You cannot get stack frame information or in any fashion debug functions that were not compiled by Perl, such as those from C or C++ extensions.

C や C++ 拡張のような、Perl でコンパイルされていないものに対して スタックフレーム情報やあらゆるデバッグ関数を使うことはできません。

If you alter your @_ arguments in a subroutine (such as with shift or pop), the stack backtrace will not show the original values.

サブルーチン内で(shiftpop を使って) @_ 引数を変更した場合、 スタックバックトレースで元の値を表示することはできません。

The debugger does not currently work in conjunction with the -W command-line switch, because it itself is not free of warnings.

デバッガは現在のところ -W コマンドラインスイッチと同時に使うことは できません; これ自身が警告から逃れられないからです。

If you're in a slow syscall (like waiting, accepting, or reading from your keyboard or a socket) and haven't set up your own $SIG{INT} handler, then you won't be able to CTRL-C your way back to the debugger, because the debugger's own $SIG{INT} handler doesn't understand that it needs to raise an exception to longjmp(3) out of slow syscalls.

(キーボードやソケットからの wait, accept, readなどの)遅い システムコールを実行中で、独自の $SIG{INT} ハンドラを設定していない場合、 デバッガに戻ってくるために CTRL-C を使うことはできません; これは、デバッガ自身の $SIG{INT} ハンドラが遅いシステムコールから longjmp(3) で出るための例外を発生させる必要性を理解しないからです。