linuxBean14.04(32)GNU Make Debugger, Remake:その3

2015-06-12

旧ブログ

t f B! P L

前の関連記事:linuxBean14.04(31)GNU Make Debugger, Remake:その2


remakeはMakefileにブレークポイントも設定できます。

ブレークポイントをターゲット名で設定する


break/bでブレークポイントを設定できるのですが、どこでも設定できるわけではありません。

まずはターゲット名にブレークポイントを設定してみます。

ターゲット名はinfo targetsで得られます。

remake<17> info targets
Makefile:59:
.PHONY
.S
.S.o
.S.s
../../../settings/stdtarget.mk:19:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.class
Makefile:83:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.jar
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.mf
Makefile:65:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
Makefile:82:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.jar
Makefile:69:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.mf
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/HelloTextTableShape.class
Makefile:84:
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/HelloTextTableShape.jar
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/HelloTextTableShape.mf
Makefile:60:
ALL
FirstLoadComponent.java
Makefile:86:
FirstStepsExamples
FirstUnoContact.java
HelloTextTableShape.java
Makefile
Makefile:99:
clean

読み込んでいるすべてのMakefileのターゲット名が表示されるのですが、Makefileから読み込まれたMakefileのターゲット名は略しています。

なぜかFirstLoadComponent.classだけ違うファイルにあるように表示されてしまいます。

今回使っているMakefileではパターンで表示されている76行目のルールのターゲットと、82行目、83行目、84行目のターゲット名が同じなのでおかしくなっているのかもしれません。

他のターゲット名でもMakefileでの行番号はルールのターゲットになっている行とは一致していないのが多いですが、ブレークポイントの設定はターゲット名で行うので、単にこれはターゲット名のリストとみればよいです。

ブレークポイントの設定はinfo targetsで表示される通りのターゲット名で指定します。

remake<18> b /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.jar
Breakpoint 1 on target /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.jar: file Makefile, line 83.
remake<61> b
Num Type           Disp Enb Target     Location
  1 breakpoint     keep y   /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.jar at /opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps/Makefile:83

b ターゲット名、でブレークポイントを設定できます。

引数無しでbを実行するとブレークポイント一覧が表示されます。

cかRとするとブレークポイントに設定されたターゲットの部分で止まります。
(Rとするときはターゲットがすでに生成されているかもしれないことを考える必要があります。)

ブレークポイントの削除はbで表示されるブレークポイント番号を引数にして、d [ブレークポイント番号]、でできました。

ところがブレークポイントがない状態で、引数無しでdを実行するとNo Breakpoint number 1 set.がでてCtrl+Cでしか止まらなくなりました。

たまたまbと間違えてdとしただけなので、引数無しでdすることはないのでしょうけど。

行番号でブレークポイントを設定する


ブレークポイントに設定できる行番号はかなり限定されます。

info/i linesでブレークポイントを設定できる行番号がわかります。

remake<19> i lines
Makefile:
      59: .PHONY
      60: ALL
      65: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/%.class (pattern)
      69: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/%.mf (pattern)
      76: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/%.jar (pattern)
      82: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.jar
      83: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstLoadComponent.jar
      84: /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/HelloTextTableShape.jar
      86: FirstStepsExamples
      95: %.run (pattern)
      99: clean
../../../settings/stdtarget.mk:
      19: .SUFFIXES
      21: .SECONDARY
      28: install
      30: /home/pq/libreoffice5.0_sdk/LINUXexample.out/misc/oosdk_cpp_types.flag

これにでてくる行番号を指定して、b [行番号]、でブレークポイントを設定できます。

ただし、設定できるのはパターンを使っていないターゲット(最後に「(pattern)」の表記がない行)に対してだけです。

例えば、b 76とすると** No support of breakpoints on target patterns yet.といわれてブレークポイントの設定はできません。

ブレークするタイミングprereq/run/endを指定する


ブレークポイントの設定時の引数はブレークポイントの設定場所に加えて、ブレークするタイミングを指定する引数を指定できます。

ブレークするタイミングの指定にはprereq/run/endの3種類あります。

prereqはブレークポイントに指定されたルールに達した時点で停止します。(デフォルト)
(Program stopped before rule-prequisite checking. )

runはルールの依存関係をチェックしたあとで停止します。
(Program is stopped after rule-prequisite checking.)

endはルールのコマンドを実行したあとに停止します。
(Program is stopped after running rule command(s).)

どの状態で停止しているかはinfo programで知ることができます。

ターゲット/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.classにブレークポイントを設定して比較してみます。

make clean (makeで作成したファイルのリセット)
remake --debugger (remakeの起動)
b /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class prereq/run/end (ブレークポイントの設定)
b (ブレークポイント一覧の出力)
c (ブレークポイントまで実行)
info program (停止状態の確認)

以下prereq/run/endそれぞれの場合についてこれら一覧のコマンドを実行した結果です。

prereq
remake<0> b /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class prereq
Breakpoint 1 on target /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class.
remake<1> b
Num Type           Disp Enb Target     Location
  1 breakpoint     keep y   /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
remake<2> c
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
mkdir -p /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-> (/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps/??:0)
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class: FirstUnoContact.java
remake<3> info program
Starting directory `/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps'
Program invocation:
 remake  --debugger
Recursion level: 0
No line number info recorded.

Program stopped before rule-prequisite checking. 
run
remake<0> b /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class run
Breakpoint 1 on target /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class.
remake<1> b
Num Type           Disp Enb Target     Location
  1 breakpoint     keep y   /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
remake<2> c
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
mkdir -p /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.. (/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps/??:0)
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
remake<3> info program
Starting directory `/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps'
Program invocation:
 remake  --debugger
Recursion level: 0
No line number info recorded.

Program is stopped after rule-prequisite checking.
end
remake<0> b /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class end
Breakpoint 1 on target /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class.
remake<1> b
Num Type           Disp Enb Target     Location
  1 breakpoint     keep y   /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
remake<2> c
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
mkdir -p /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
mkdir -p /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
##>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
"/usr/bin/javac"  -classpath "/opt/libreofficedev5.0/sdk/../program/classes/juh.jar:/opt/libreofficedev5.0/sdk/../program/classes/jurt.jar:/opt/libreofficedev5.0/sdk/../program/classes/ridl.jar:/opt/libreofficedev5.0/sdk/../program/classes/unoloader.jar:/opt/libreofficedev5.0/sdk/../program/classes/unoil.jar::/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples" -d /home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples FirstUnoContact.java
##<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<- (/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps/Makefile:65)
/home/pq/libreoffice5.0_sdk/LINUXexample.out/class/FirstStepsExamples/FirstUnoContact.class
remake<3> info program
Starting directory `/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps'
Program invocation:
 remake  --debugger
Recursion level: 0
Line 65 of "/opt/libreofficedev5.0/sdk/examples/DevelopersGuide/FirstSteps/Makefile"
Program is stopped after running rule command(s).

ブレークポイント一覧ではどの状態でブレークポイントを設定したのかわかりませんね。

endの場合は一目瞭然ですが、prereqなのかrunなのかはinfo programをしないとわかりにくいですね。

remakeをDDDで使う


Remake with ddd · rocky/remake Wiki

linuxBean14.04(27)GeanyとシェルスクリプトのデバッグでインストールしたDDDがremakeに対応していると書いてあります。

 ddd --make Makefile

これで確かにDDDでremakeが使えました。


単にDDDのコンソールでremakeが動くということしかわかりませんでした。

参考にしたサイト


Set Breaks - GNU Make Debugger, Remake
remakeでMakefileにブレークポイントを設定する方法。

Remake with ddd · rocky/remake Wiki
DDDでremakeを使えましたがGUIのメリットは感じられませんでした。

次の関連記事:linuxBean14.04(33)失敗したLibreOfficeSDKの例を再make:その1

ブログ検索 by Blogger

Translate

最近のコメント

Created by Calendar Gadget

QooQ