HP-UX General
1819687 メンバー
3333 オンライン
109605 解決策
新規ポスト

コンパイルオプション(-g)判別方法

 
H_Fus
新しいメンバー

コンパイルオプション(-g)判別方法

お世話になります。

HP-UX(11.23Itanium)にて、Cプログラムのコンパイルオプションが正しく指定されているか、モジュールから割り出す必要に迫られております。

具体的には、-g オプション(デバッグモード)の指定有無を知りたいのですが、方法が分からず困っております。

試しにgdbで実行モジュールを開くと、lコマンドにて-gを指定しないモジュールでも、行番号が表示され、判断がつきません。

どうやら、シンボル・テーブル(+行番号情報?)は、-gを指定しなくとも、モジュールに組み込まれるようなのですが、-gによるデバッグ情報を付加したかどうか知る方法はないでしょうか。

コマンド等、もしご存知の方がおられましたら、ご教授いただけますようお願いいたします。

$ uname -r

B.11.23

$ ls

main.c main.g.c mk

$ cat mk

set -x

cc -c main.c

cc -o a.out main.o

cc -g -c main.g.c

cc -g -o g.out main.g.o

$ mk

+ cc -c main.c

+ cc -o a.out main.o

+ cc -g -c main.g.c

+ cc -g -o g.out main.g.o

$ gdb a.out

HP gdb 5.4.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.

Copyright 1986 - 2001 Free Software Foundation, Inc.

Hewlett-Packard Wildebeest 5.4.0 (based on GDB) is covered by the

GNU General Public License. Type "show copying" to see the conditions to

change it and/or distribute copies. Type "show warranty" for warranty/support.

..

(gdb) l

1 #include

2 int main()

3 {

4 printf("test\n");

5 }

(gdb) quit

$ gdb g.out

HP gdb 5.4.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.

Copyright 1986 - 2001 Free Software Foundation, Inc.

Hewlett-Packard Wildebeest 5.4.0 (based on GDB) is covered by the

GNU General Public License. Type "show copying" to see the conditions to

change it and/or distribute copies. Type "show warranty" for warranty/support.

..

(gdb) l

1 #include

2 int main()

3 {

4 printf("test\n");

5 }

(gdb) quit

$
3件の返信3
st
頻繁なアドバイザー

コンパイルオプション(-g)判別方法

footprints コマンドが便利だと思います。

http://docs.hp.com/ja/B2355-60129/footprints.1.html

昔はこのコマンドが存在しなかったので、elfdump -dc a.out でオプションを調べたりしていました。

ご参考までに。
H_Fus
新しいメンバー

コンパイルオプション(-g)判別方法

迅速なご回答ありがとうございました。

11iv2でfootprints コマンドは残念ながらなさそうでしたので、elfdumpコマンドを使用することにしました。

↓ -g なしでコンパイルしたモジュール ("debug"という文字が含まれない。)

$ elfdump -dc a.out |grep debug

$

↓-g つきでコンパイルしたモジュール("debug"という文字が含まれる。)

$ elfdump -dc g.out |grep debug

ecom options = -architecture 32 -ia64abi all -ext on -lang c -exception off -sysdir /usr/include -inline_power 1 -link_type dynamic -fpeval float -tls_dyn on -target_os 11.23 -rodata cond --sys_include /usr/include -debug debugG1 -ucode hdriver=optlevel%1% -plusolistoption -Ol06const! -plusolistoption -Ol13moderate! -plusooption -Oq01,al,ag,cn,sz,ic,vo,Mf,Po,es,rs,Rf,Pr,sp,in,cl,om,vc,pi,fa,pe,rr,pa,pv,nf,cp,lx,Pg,ug,lu,lb,uj,dn,sg,pt,kt,em,np,ar,rp,dl,fs,bp,wp,pc,mp,lr,cx,cr,pi,so,Rc,fa,ft,fe,ap,st,lc,Bl,sr,ib,pl,sd,ll,rl,dl,Lt,ol,fl,lm,ts,rd,dp,If!

ありがとうございました。
st
頻繁なアドバイザー

コンパイルオプション(-g)判別方法

解決してよかったですね。

footprints コマンドは、OE の版数が古いと存在しません。2007 年 6 月版以降であれば "linker + fdp" のパッチに含まれて標準インストールです。ご参考までに。