Michael Mueller, IT Consulting

Dipl. Math. Michael Mueller

GDB for Sun C Compilers (Solaris/SPARC)

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 GCC. But it is almost impossible to debug Sun C compiled programs, especially if they are 64 bit (cc -xarch=v9).

The purpose of this project is to

The following list of bugs and the patches provided are for gdb version 6.2 You can obtain the source code from GDB: The GNU Project Debugger

Table of contents

List of Bugs

The columns in the list contain the following information:

Sun C specific bugs in gdb 6.2
No Description Gdb PR Status
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)
no entry unresolved
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

Patches for GDB 6.2

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:

Running Configure

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 ./configure
To configure a 64 bit gdb using a Sun compiler:
CC="cc -xarch=v9" ./configure
To configure a 64 bit gdb debuggable gdb using a Sun compiler:
CC="cc -xarch=v9 -xs" ./configure

To configure a 32 bit gdb using gcc:
CC=gcc ./configure
To configure a 64 bit gdb using gcc:
CC="gcc -m64" ./configure

Using gdb with Sun C

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