Solaris10 で dbx を使ってみた。
Oracle 9iR2 に同梱されているサンプルプログラム(Pro*C)をデバッグオプション付でコンパイルし、dbx を使ってステップ実行などしてみた。
- env_precomp.mk.debug を作成する。こいつを使うとデバッグオプション付でコンパイルされる。
$ cd /export/home/oracle/app/oracle/product/9.2.0/precomp/lib
$ cp env_precomp.mk env_precomp.mk.debug
$ vi env_precomp.mk.debug
CC=/opt/SUNWspro/bin/cc -g -m64
$ mkdir -p /export/home/oracle/work
$ cd /export/home/oracle/work
$ cp $ORACLE_HOME/precomp/demo/proc/demo_proc64.mk ./
$ cp $ORACLE_HOME/precomp/demo/proc/sample1.pc ./
- サンプルmakefileを変更して、env_precomp.mk.debug を使うようにする。
$ vi demo_proc64.mk
include $(ORACLE_HOME)/precomp/lib/env_precomp.mk.debug
#define UNAME_LEN 20
#define PWD_LEN 40
#define DBNAME_LEN 10 # ← 追記
...
strncpy((char *) password.arr, "TIGER", PWD_LEN);
password.len =
(unsigned short) strlen((char *) password.arr);
# ← 追記
strncpy((char *) dbname.arr, "orcl", DBNAME_LEN); # ← 追記
dbname.len = # ← 追記
(unsigned short) strlen((char *) dbname.arr); # ← 追記
...
EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbname; # ← 「USING :dbname」を追記
$ /usr/ccs/bin/make -f demo_proc64.mk build EXE=sample1 OBJS=sample1.o
$ ./sample1
Connected to ORACLE as user: SCOTT
Enter employee number (0 to quit): 7369
Employee Salary Commission
-------- ------- ----------
SMITH 800.00 NULL
Enter employee number (0 to quit):
- dbx を使ってみる(別のターミナルセッションを開く)。
$ ps -ef | grep "[s]ample1"
oracle 21378 3073 0 15:48:14 pts/1 0:00 ./sample1
$ /opt/SUNWspro/bin/dbx - 21378
For information about new features see `help changes'
To remove this message, put `dbxenv suppress_startup_message 7.6' in your .dbxrc
Reading sample1
Reading ld.so.1
Reading libclntsh.so.9.0
Reading libnsl.so.1
Reading libsocket.so.1
Reading libgen.so.1
Reading libdl.so.1
Reading libaio.so.1
Reading librt.so.1
Reading libm.so.2
Reading libthread.so.1
Reading libc.so.1
Reading libwtc9.so
Reading libmd5.so.1
Reading libc_psr.so.1
Attached to process 21378
t@1 (l@1) stopped in _read at 0xffffffff7d5ce794
0xffffffff7d5ce794: _read+0x0008: ta %icc,0x0000000000000040
Current function is main (optimized)
344 gets(temp_char);
(dbx) step # ← ステップ実行(関数内に入り込む)
t@1 (l@1) stopped in main (optimized) at line 346 in file "sample1.c"
346 if (emp_number == 0)
(dbx) next # ← ステップ実行(関数実行後に次の行で実行停止する)
t@1 (l@1) stopped in main (optimized) at line 362 in file "sample1.c"
362 sqlstm.sqlvsn = 12;
(dbx) list # ソースコードを表示する
346 if (emp_number == 0)
347 break;
348
349 /* Branch to the notfound label when the
350 * 1403 ("No data found") condition occurs.
351 */
352 /* EXEC SQL WHENEVER NOT FOUND GOTO notfound; */
353
354
355 /* EXEC SQL SELECT ename, sal, comm
(dbx) print emp_number
emp_number = 0
[参考]
http://docs.sun.com/app/docs/doc/805-7883/6j7dojf62?l=ja&a=view
monjyu.biz