Jdb-basic-commands
提供:Dev Guides
JDB-基本コマンド
この章では、JDBの基本的なコマンドについて説明します。 セッションの起動後、これらのコマンドはプログラムのデバッグに使用されます。
以下は、デバッグに使用されるコマンドのリストです。
Name | Description |
---|---|
help or ? | The most important *JDB *command; it displays a list of recognized commands with a brief description. |
run | After starting* JDB* and setting the necessary breakpoints, you can use this command to start execution and debug an application. |
cont | Continues execution of the debugged application after a breakpoint, exception, or step. |
Displays Java objects and primitive values. | |
dump | For primitive values, this command is identical to print. For objects, it prints the current value of each field defined in the object. Static and instance fields are included. |
threads | Lists the threads that are currently running. |
thread | Selects a thread to be the current thread. |
where | Dumps the stack of the current thread. |
例
次の例の Add というサンプルクラスがあると仮定します。
Add.java
public class Add
{
public int addition( int x, int y)
{
int z = x + y;
return z;
}
public static void main( String ar[ ] )
{
int a = 5, b = 6;
Add ob = new Add();
int c = ob.addition(a,b);
System.out.println("Add: " + c);
}
}
次のコマンドを使用して、このクラスAdd.javaをコンパイルします。
\>javac Add.java
Run
このコマンドは、デバッグのためにJDBに追加されるメインクラスファイルを実行します。 次のコマンドを実行して、Addクラスを実行します。
\>jdb Add
initializing jdb …
>run
これらのコマンドを実行すると、次の出力が表示されます。