GDB, the GNU Debugger,
is used on a large number of platforms. On Solaris SPARC systems, the current
version 6.2 works well for debugging programs compiled with
But it is almost impossible to debug Sun C compiled programs, especially
if they are 64 bit
The purpose of this project is to
document Sun C specific gdb bugs.
provide preliminary patches that allow gdb to work with Sun C in 32 and 64 bit mode.
incorporate mature versions of these patches in the current source branch
of gdb by sending them to the
monitor GDBs stability with Sun C on Solaris/SPARC in the future
The following list of bugs and the patches provided are for gdb version 6.2.
You can obtain the source code from
The columns in the list contain the following information:
My bug number
A reference to gdb's
Possible values are:
|unresolved:||no patch available|
|patched:||patch available, not committed into current gdb source|
|committed:||patch available, committed into current gdb source|
|1||breakpoint on a function name or first line in function does not work||breakpoints/1682||patched|
|2||printing of local variables fails for 64 bit programs||gdb/1669||patched, partially committed|
|3||backtrace for Sun C -O compiled programs doesn't work||backtrace/1685||patched|
|4||gdb SEGVs with prototype of function returning struct per value||no entry||patched|
|5||print command for structs in 64 bit programs prepends garbage to member names||no entry||patched|
|6||backtraces for -O compiled programs doesn't work after some 'stepi's||backtrace/1688||unresolved|
|7||no hardware watchpoints for multithreaded programs||breakpoints/1686||patched|
|8||local variables in inner blocks are unknown to gdb||no entry||unresolved|
|9||printing of local variables fails for 64 bit programs with
-xdebugformat=dwarf (-xdebugformat is new in C 5.5)
|10||struct function parameters passed by value are printed with garbage values||no entry||unresolved|
|11||^C doesn't work after attaching forked process||gdb/1422 (by Woody LaRue)||patched|
|12||gdb cannot access source file||gdb/1684||unresolved|
These patches are published under the GNU General Public License. They are provided "as is" and there is no warranty for the correct functioning of the patched program.
The patches are intended for GDB 6.2 on Solaris/SPARC. They should fix bugs as shown in the above bug list. They should not impare gdb's ability to work with GCC compiled programs on this platform. But they are preliminary and have not been tested on any other platform (not even Solaris Intel).
To apply the patches:
Obtain the gdb 6.2 sources from
Change to the top directory gdb-6.2 and run the configure script
that comes with the sources. For further details, see
Run "make". (I had no problems using Sun's make.) This produces an unpatched version of gdb in gdb-6.2/gdb/gdb. You may want to rename it and keep it for reference purposes.
Download my patchfile gdb.2004-08-05.patch.gz into the gdb-6.2/gdb subdirectory of the source tree where the gdb binary from the previous step resides. Unpack it using
gunzip gdb.2004-08-05.patch.gz(The "2004-08-05" in the patchfile's name will change if I upload new releases.)
Apply the patch using:
cd gdb-6.2/gdb patch -p0 < gdb.2004-08-05.patch
Run "make" in the gdb-6.2/gdb subdirectory. This will produce the patched binary in gdb-6.2/gdb/gdb.
Install the patched gdb by running "make install" or by copying gdb/gdb to your preferred loaction.
You can select either a 32 bit or a 64 bit configuration for gdb. To debug a 64 bit program, you need a 64 bit gdb. It also can debug 32 bit programs. However, if you want to use hardware watchpoints, you must use a 32 bit gdb for a 32 bit program and vice versa. You might want to produce both, one after the other.
You also can choose which compiler (GCC or Sun C) to use. Which compiler you choose is irrelevant as long as you don't run into a compiler bug. I used Sun C 5.4.
To configure a 32 bit gdb using a Sun compiler:
CC=cc ./configureTo configure a 64 bit gdb using a Sun compiler:
CC="cc -xarch=v9" ./configureTo configure a 64 bit gdb debuggable gdb using a Sun compiler:
CC="cc -xarch=v9 -xs" ./configureTo configure a 32 bit gdb using gcc:
CC=gcc ./configureTo configure a 64 bit gdb using gcc:
CC="gcc -m64" ./configure
More recent Sun C compilers store debugging information in object files where gdb cannot find it. They don't normally put them into the executables. To make the C compiler do this, use "cc -g -xs" if you have more than a single module to compile. For example:
cc -c -g -xs t1.c cc -c -g -xs t2.c cc -g -xs t1.o t2.o -o t