December 13,2006

在Solaris 8 (SunOS 5.8)上面安裝gdb 6.0

嗯,Solaris都出到10了,我的環境裡面都還是Solaris 8。

這也沒什麼好意外的,就好像Microsoft Windows Vista都要出了,我的筆電卻才從Windows 2000換到XP不久。

就好像我雖然不寫程式,卻因為要幫遠在天邊的國外R&D同事抓程式臭蟲,必須要裝gdb這個自由軟體debugger一樣。

我在說什麼啊,不亂扯了,把我在Solaris 8 (SunOS 5.8)上面安裝gdb 6.0的經過簡單紀錄一下吧:

先到www.sunfreeware.com下載gdb:
http://www.sunfreeware.com/index.html
右邊點選作業系統版本+CPU版本(我的是SPARC/Solaris 8),然後再從右邊的套件選單點選gdb-6.0

中間應該會出現底下這一段:

gdb-6.0-sol8-sparc-local.gz The GNU Debugger - installs in /usr/local. This version was compiled with gcc 3.2.2 and requires that the libiconv package also be installed.


點選gdb-6.0-sol8-sparc-local.gz下載,然後放在機器的/tmp/底下。

用root帳號登入,然後執行底下的指令:

root@solaris8 # cd /tmp
root@solaris8 # gunzip gdb-6.0-sol8-sparc-local.gz
root@solaris8 # /usr/sbin/pkgadd -d gdb-6.0-sol8-sparc-local

The following packages are available:
1 SMCgdb gdb
(sparc) 6.0

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]: (這邊我按Enter)

Processing package instance <SMCgdb> from </tmp/gdb-6.0-sol8-sparc-local>

gdb
(sparc) 6.0
Free Software Foundation
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
7 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.

The following files are already installed on the system and are being
used by another package:
* /usr/local/bin/gdb
* /usr/local/include/ansidecl.h
* /usr/local/include/bfd.h
* /usr/local/include/bfdlink.h
* /usr/local/info/standards.info
* /usr/local/lib/libbfd.a
* /usr/local/lib/libbfd.la
* /usr/local/lib/libiberty.a
* /usr/local/lib/libopcodes.a
* /usr/local/lib/libopcodes.la

* - conflict with a file which does not belong to any package.

Do you want to install these conflicting files [y,n,?,q] y (這邊我打y再按Enter)
## Checking for setuid/setgid programs.

Installing gdb as <SMCgdb>

## Installing part 1 of 1.
/usr/local/bin/gdb
/usr/local/doc/gdb/COPYING
/usr/local/doc/gdb/COPYING.LIB
/usr/local/doc/gdb/README
/usr/local/include/ansidecl.h
/usr/local/include/bfd.h
/usr/local/include/bfdlink.h
/usr/local/include/dis-asm.h
/usr/local/include/symcat.h
/usr/local/info/annotate.info
/usr/local/info/bfd.info
/usr/local/info/bfd.info-1
/usr/local/info/bfd.info-2
/usr/local/info/configure.info
/usr/local/info/gdb.info
/usr/local/info/gdb.info-1
/usr/local/info/gdb.info-2
/usr/local/info/gdb.info-3
/usr/local/info/gdbint.info
/usr/local/info/mmalloc.info
/usr/local/info/stabs.info
/usr/local/info/standards.info
/usr/local/lib/libbfd.a
/usr/local/lib/libbfd.la
/usr/local/lib/libiberty.a
/usr/local/lib/libmmalloc.a
/usr/local/lib/libopcodes.a
/usr/local/lib/libopcodes.la
/usr/local/man/man1/gdb.1
[ verifying class <none> ]

Installation of <SMCgdb> was successful.
root@solaris8 #

裝好了,來跑跑看,立刻就遇到問題:
austin@solaris8:bin> which gdb
/usr/local/bin/gdb
austin@solaris8:bin> gdb
ld.so.1: gdb: fatal: libiconv.so.2: open failed: No such file or directory
Killed
austin@solaris8:bin>

記得嗎?網站上有說

libiconv-1.11-sol8-sparc-local.gz GNU libiconv provides an iconv() implementation for use on systems which do not have one - installs in /usr/local. Dependencies: libintl and libgcc_s.so.1 from libgcc-3.4.6 or gcc-3.4.6 or higher.


原來是套件相依性的問題,再接再厲,點選libiconv-1.11-sol8-sparc-local.gz 下載,然後放在機器的/tmp/底下。

root@solaris8 # cd /tmp
root@solaris8 # gunzip libiconv-1.11-sol8-sparc-local.gz
root@solaris8 # /usr/sbin/pkgadd -d libiconv-1.11-sol8-sparc-local

The following packages are available:
1 SMCliconv libiconv
(sparc) 1.11

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:(這邊我按Enter)

Processing package instance <SMCliconv> from </tmp/libiconv-1.11-sol8-sparc-local>

libiconv
(sparc) 1.11
Bruno Haible
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
8 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing libiconv as <SMCliconv>

## Installing part 1 of 1.
/usr/local/bin/iconv
/usr/local/doc/libiconv/ABOUT-NLS
/usr/local/doc/libiconv/AUTHORS
/usr/local/doc/libiconv/COPYING.LIB
/usr/local/doc/libiconv/ChangeLog
/usr/local/doc/libiconv/DESIGN
/usr/local/doc/libiconv/INSTALL.generic
/usr/local/doc/libiconv/NEWS
/usr/local/doc/libiconv/NOTES
/usr/local/doc/libiconv/PORTS
/usr/local/doc/libiconv/README
/usr/local/doc/libiconv/README.djgpp
/usr/local/doc/libiconv/README.os2
/usr/local/doc/libiconv/README.woe32
/usr/local/doc/libiconv/THANKS
/usr/local/include/iconv.h
/usr/local/include/libcharset.h
/usr/local/include/localcharset.h
/usr/local/lib/libcharset.a
/usr/local/lib/libcharset.la
/usr/local/lib/libcharset.so <symbolic link>
/usr/local/lib/libcharset.so.1 <symbolic link>
/usr/local/lib/libcharset.so.1.0.0
/usr/local/lib/libiconv.la
/usr/local/lib/libiconv.so <symbolic link>
/usr/local/lib/libiconv.so.2 <symbolic link>
/usr/local/lib/libiconv.so.2.4.0
/usr/local/lib/preloadable_libiconv.so
/usr/local/man/man1/iconv.1
/usr/local/man/man3/iconv.3
/usr/local/man/man3/iconv_close.3
/usr/local/man/man3/iconv_open.3
/usr/local/man/man3/iconvctl.3
/usr/local/share/doc/iconv.1.html
/usr/local/share/doc/iconv.3.html
/usr/local/share/doc/iconv_close.3.html
/usr/local/share/doc/iconv_open.3.html
/usr/local/share/doc/iconvctl.3.html
[ verifying class <none> ]

Installation of <SMCliconv> was successful.
root@solaris8 #

好,看起來可以執行了:

austin@solaris8:austin> which gdb
/usr/local/bin/gdb
austin@solaris8:austin> gdb
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8".
(gdb) quit
austin@solaris8:austin>

以上。

如果這篇文章對妳有幫助,歡迎妳留言讓我知道^_^

底下是我後來又遇到的問題,如果妳知道答案,也歡迎妳留言給我!

======
真正拿來跑,卻又遇到問題:

austin@solaris8:austin> gdb /export/home/austin/bin/my_executable /export/home/austin/core-061211-1131
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...Bus Error (core dumped)
austin@solaris8:austin>

查了一下,我的系統本來就有裝libgcc,不過是比較舊的3.4.1:
austin@solaris8:austin> pkginfo | grep -i gcc
application SMClibgcc libgcc
austin@solaris8:austin> pkginfo -l SMClibgcc
PKGINST: SMClibgcc
NAME: libgcc
CATEGORY: application
ARCH: sparc
VERSION: 3.4.1
BASEDIR: /usr/local/lib
VENDOR: FSF
PSTAMP: Steve Christensen
INSTDATE: Mar 21 2006 19:19
EMAIL: steve@smc.vnet.net
STATUS: completely installed
FILES: 15 installed pathnames
1 directories
4 executables
57084 blocks used (approx)

austin@solaris8:austin>

好吧,那就點選libgcc-3.4.6-sol8-sparc-local.gz下載,再次用root權限安裝:

root@solaris8 # cd /tmp
root@solaris8 # gunzip libgcc-3.4.6-sol8-sparc-local.gz
root@solaris8 # /usr/sbin/pkgadd -d libgcc-3.4.6-sol8-sparc-local

The following packages are available:
1 SMClgcc346 libgcc
(sparc) 3.4.6

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:(這邊我按Enter)

Processing package instance <SMClgcc346> from </tmp/libgcc-3.4.6-sol8-sparc-local>

libgcc
(sparc) 3.4.6
FSF
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
2 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.

The following files are already installed on the system and are being
used by another package:
/usr/local/lib/libgcc_s.so.1
/usr/local/lib/libstdc++.so.6

Do you want to install these conflicting files [y,n,?,q] y(這邊我按y再按Enter)
## Checking for setuid/setgid programs.

Installing libgcc as <SMClgcc346>

## Installing part 1 of 1.
/usr/local/lib/libg2c.so <symbolic link>
/usr/local/lib/libg2c.so.0 <symbolic link>
/usr/local/lib/libg2c.so.0.0.0
/usr/local/lib/libgcc_s.so.1
/usr/local/lib/libstdc++.so.6 <symbolic link>
/usr/local/lib/libstdc++.so.6.0.3
[ verifying class <none> ]

Installation of <SMClgcc346> was successful.
root@solaris8 #


結果還是不行:

austin@solaris8:austin> gdb /export/home/austin/bin/my_executable /export/home/austin/core-061211-1131
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...Bus Error (core dumped)
austin@solaris8:austin>

只好再試試,裝libintl-3.4.0-sol8-sparc-local.gz

root@solaris8 # cd /tmp
root@solaris8 # gunzip libintl-3.4.0-sol8-sparc-local.gz
root@solaris8 # /usr/sbin/pkgadd -d libintl-3.4.0-sol8-sparc-local

The following packages are available:
1 SMClintl libintl
(sparc) 3.4.0

Select package(s) you wish to process (or 'all' to process
all packages). (default: all) [?,??,q]:(這邊我按Enter)

Processing package instance <SMClintl> from </tmp/libintl-3.4.0-sol8-sparc-local>

libintl
(sparc) 3.4.0
FSF
Using </usr/local> as the package base directory.
## Processing package information.
## Processing system information.
2 package pathnames are already properly installed.
## Verifying disk space requirements.
## Checking for conflicts with packages already installed.
## Checking for setuid/setgid programs.

Installing libintl as <SMClintl>

## Installing part 1 of 1.
/usr/local/include/libintl.h
/usr/local/lib/libintl.a
/usr/local/lib/libintl.la
/usr/local/lib/libintl.so <symbolic link>
/usr/local/lib/libintl.so.3 <symbolic link>
/usr/local/lib/libintl.so.3.4.0
[ verifying class <none> ]

Installation of <SMClintl> was successful.
root@solaris8 #

可惡,還是不能跑我那個core

austin@solaris8:austin> gdb /export/home/austin/bin/my_executable /export/home/austin/core-061211-1131
GNU gdb 6.0
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.8"...Bus Error (core dumped)
austin@solaris8:austin>

Posted by ystuan at 樂多Roodo! │13:52 │回應(2)引用(0)ItchScratching
樂多分類:網路/3C 共同主題:自由軟體 工具:編輯本文
Ads by Roodo! 

引用URL

http://cgi.blog.roodo.com/trackback/2566930
回應文章
謝謝你這一篇文章。我是新手上路。我要在 Solaris 9 内安 libgcc-3.4.6。我在 Internet 上用 Google 找。一找就找到你這篇文章。

不知道,你後來用不用到 gdb?
Posted by biop at October 22,2007 15:41
biop,

謝謝妳的鼓勵!

我很久沒有用到 gdb 了,希望不要再用到了 :p
Posted by 畢竟不是程式設計師的PowerOp at October 24,2007 00:11