Re: GDB 5.1 on Solaris 2.8

debashis mahata
2001-11-26T04:16:00Z

Hi all,

I also hit this problem. Probably this is a problem with
"Sun WorkShop 6
update 2 C 5.3" compiler. This compiler does not generate the last back
slash ("/") in the first N_SO stab that represents the directory name.
The second N_SO is actually represents the source file name. GDB
identify the directory name using the last '/' as an indicator. For the
program

$pwd
/h/mahatad/DBG/GDB
$cat a.c
int
main (void) {
int a = 1;
}
$

The N_SO stab entries are -

With "Sun WorkShop 6 update 2 C 5.3" -

"/h/mahatad/DBG/GDB" ,64, 0, 0, 0
"a.c" ,64, 0, 3, 0

With the old version of compiler -

"/h/mahatad/DBG/GDB/" ,64, 0, 0, 0
"a.c" ,64, 0, 3, 0

It is clear that new compiler does not generate the last '/' in first
N_SO stab.

Because of that GDB takes "/h/mahatad/DBG/GDB" as a file name. The
corresponding code is in the partial-stab.h -
case N_SO:
{
....
p = strrchr (namestring, '/');
if (p && *(p + 1) == '\000')
continue; /* Simply ignore directory name SOs */

}
GDB is not ignoring the directory name. This requires a fix. Most
probably another fix is required in dbxread.c (function -
process_one_symbol()) for N_SO case. The corresponding code -
case N_SO:
.....
start_stabs ();
start_symtab (name, NULL, valu);
record_debugformat ("stabs");
break;

Here, the 'name' is again a directory name without the last back slash.

I have put some fix for these two places in my local GDB source. After
the fix -

$cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15
$cc -g -xs a.c
$/vob/opnpde/solaris-sparc/debug/package/00.00.00.00/bin/gdb a.out
GNU gdb 4.18 + 02.00.01.00 (sparc64-sun-solaris2.7),
Copyright 1998 Free Software Foundation, Inc...
(gdb) list
1 int
2 main (void) {
3 int a = 1;
4 }
(gdb)

I found another problem with this compiler. The structures are suppose
to end with two consecutive ';'. GDB logic depends upon that. But this
compiler generate only one ';'. Just for an example -

For the structure
struct node{
int i;
char c;
};

With "Sun WorkShop 6 update 2 C 5.3" -
"node:T(0,21)=s8i:(0,3),0,32;c:(0,1),32,8;" ,80, 0, 8, 0

With the old version of compiler -
"node:T(0,21)=s8i:(0,3),0,32;c:(0,1),32,8;;" ,80, 0, 8, 0

Again it is clear the new compiler does not generate the last ';' and
this will break the GDB logic in read_struct_fields() function (file:
stabsread.c).

Thanks,
debashis mahata

----- Original Message -----
From: Eli Zaretskii <eliz@is.elta.co.il>
Date: Sunday, November 25, 2001 2:08 pm
Subject: Re: GDB 5.1 on Solaris 2.8

>
> On Sat, 24 Nov 2001, Dan Nicolaescu wrote:
>
> > > $ gdb a.out
> > > gdb> list
> > > /opt/src/devel/gdb-5.1: Is a directory.
> >
> > Well, it works for me... But it seems that you have a newer
> version of
> > the Sun compiler than I do:
> >
> > cc -V
> > cc: Sun WorkShop 6 update 1 C 5.2 2000/09/11
>
> Thanks to everyone who replied; -xs seems to be what I need.
>
> The example above works for me as well, but I have an even older
> version of the compiler.
>
> However, it sounds like turning on optimizations makes GDB debugging
> impossible with this compiler. Is that expected? Am I spoiled by
> GCC?
>