This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb/269: Gdb can not handle structure stabs for which the last ';' is missing



>Number:         269
>Category:       gdb
>Synopsis:       Gdb can not handle structure stabs for which the last ';' is missing
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 03 22:58:02 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        All
>Organization:
>Environment:
Platform: sun4u sparc SUNW,Ultra-Enterprise
OS: Sun Solaris 5.8
Compiler: Sun WorkShop 6 update 2 C 5.3 2001/05/15
>Description:
This problem was observed while using Gdb on code that is 
compiled with Sun C Compiler Forte 6 update 2.( cc - 5.3)

The Sun C compiler with update 2 does not generate the 
last ';' at the end of structure / union stabs. Also it is 
not documented that last ';' should be present.

Problem with Gdb :
                  Assumes that lasts ';' should be present 
and since it is not in place for update 2 Sun C compiler, 
GDB sometimes hangs or giving core.

example: 
For the structure 
struct node{
		int I;
		char C;
	};

With old Compiler - 
$cc -V
cc: WorkShop Compilers 5.0 98/12/15 C 5.0

the generated stab is - 
"node:T(0,21)=s8I:(0,3),0,32;C:(0,1),32,8;;"

With new update 2 compiler - 
$cc -V
cc: Sun WorkShop 6 update 2 C 5.3 2001/05/15

the generated stab is -
"node:T(0,21)=s8I:(0,3),0,32;C:(0,1),32,8;"

It is clear that the new compiler does not generate 
the last ';'. But the GDB logic depends upon that.
The corresponding GDB code is in file stabsread.c 
(function: read_struct_fields()), where Gdb searches for 
the last ';' - 
  /* Read each data member type until we find the terminating ';' at the end of
     the data member list, or break for some other reason such as finding the
     start of the member function list. */
 
  while (**pp != ';')
    {
     .....   

>How-To-Repeat:
 
>Fix:
Since it is not guaranteed that last ';' should be 
present, it is better to check for the '\0' along 
with a ';' check. This will be able to resolve both 
double ';' and single ';'.

The correct code may be like this - 

File: stabsread.c
Function: read_struct_fields()

  /* Read each data member type until we find the terminating ';' at the end of
     the data member list, or break for some other reason such as finding the
     start of the member function list. */
  /* Stab string for structure/union does not end with two ';' in
     SUN C compiler 5.3 i.e. F6U2, hence check for end of string. */
  while (**pp != ';' && **pp != '\0')
    {
    ....

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name=" "
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=" "


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]