Hello PL/I World アプリケーションのデバッグ

アプリケーションの変更

デバッグ機能の確認に役立つコードをアプリケーションに追加します。

  1. エディターで helloworld.pli プログラムを開きます。
  2. PUT SKIP LIST 文の行の前に次のコードを追加します。:
      DCL SourceString    CHAR(10);
      DCL testchar        CHAR;
      DCL loop            FIXED BIN(8);
      
      SourceString = "AAbbAAbbCC";
      DO loop = 1 TO 10 BY 1;
        testchar = SUBSTR(SourceString, loop, 1);
        IF testchar = "A" THEN
          SUBSTR(SourceString, loop, 1) = "D";
      END;
      PUT SKIP LIST(SourceString);
      
      loop = 1;
      DO WHILE (loop < 10) UNTIL (SUBSTR(SourceString, loop, 1) = "C");
        SUBSTR(SourceString, loop, 1) = "Q";
        loop = loop + 1;
      END;
    

SourceString 変数は文字列で、初期値は "AAbbAAbbCC" です。この文字列の一部の文字がプログラムの実行中に置換されます。

デバッグ構成の作成

  1. PL/I エクスプローラーで [HelloPLIWorld] を選択し、メイン メニューから [Run > Debug Configurations] をクリックします。
  2. [PL/I Application] ツリー項目をダブルクリックして、新しいデバッグ構成を作成します。
  3. 構成の名前として「HelloPLIWorld」と入力します。

    この構成では、実行するプロジェクトとして HelloPLIWorld、実行するメイン プログラムとして New_Configuration.bin/HelloPLIWorld.exe (Windows) または New_Configuration.bin/HelloPLIWorld (UNIX) を使用します。

  4. [Debug] をクリックします。

    You are prompted to save and launch before you start debugging.Click OK.

    You are prompted to switch to the debug perspective.Click Yes to confirm.デバッガーが起動して、プログラムの最初の行 (PROC 文) で停止します。

    [Debug] パースペクティブに表示されるビューには次のようなものがあります。

    • [Debug] ビュー - 現在アクティブなスレッドが表示されます。
    • [Editor] - helloworld.pli プログラムと、プログラム内のデバッガーの位置が表示されます。
    • [Expressions] - 式を監視します。
    • [Outline] - ステップ実行しているプログラムの構造のアウトラインが表示されます。
    • [Breakpoints] - ブレークポイントを監視します。

コードのステップ実行

You can now step through the code and see how the value of the SourceString changes:

  1. F5 キー ([Step Into]) を押して、コードのステップ実行を開始します。

    プログラムの最初の行が実行されて、カーソルがコードの次の行に移動します。

  2. [Expressions] ビューを開きます。
  3. Click the + in it and type SourceString as you are going to monitor this variable during debugging.
  4. 再び F5 キーを押します。

    SourceString の値を初期化する文が実行されます。

  5. Step through the next few lines in the same way and see how the value of the SourceString variable changes in the Expressions view.
  6. F8 を押してプログラムを終了します。

    デバッグが停止します。

後で参照できるようにプロジェクトを保存してください。

次のステップ

PL/I 開発での Eclipse の使用」のセクションに進みます。