[patch/hpux] hpread.c: fix static data members

Michael Elizabeth Chastain mec.gnu@mindspring.com
Wed Jan 7 13:20:00 GMT 2004


This patch fixes a problem with static data members in hpread.c.

This code got hit by this "clean up bitsize" patch:

  2002-11-10  Daniel Jacobowitz  <drow@mvista.com>

          * gdbtypes.h (struct main_type): Move artificial flag out of
          loc.  New member of ``struct field'' named static_kind.  Reduce
          overloaded meaning of bitsize.
          (FIELD_ARTIFICIAL, SET_FIELD_PHYSNAME, SET_FIELD_PHYSADDR)
          (TYPE_FIELD_STATIC, TYPE_FIELD_STATIC_HAS_ADDR): Likewise.
          (FIELD_STATIC_KIND, TYPE_FIELD_STATIC_KIND): New macros.

Don't get me wrong, I love patches like this.  hpread.c just needs a
local bug fix to work with the new macros.

The problem is that hpread_read_struct_type still used the "set bitsize
to -1" method to signal that the method was static.  Well, setting the
bitsize to -1 no longer means that the method is static.  This code
needs to use one of the the right macros: SET_FIELD_PHYSNAME or
SET_FIELD_PHYSADDR.

The symptom of a missing "static" bit are infinite recursion when
priting a class like this:

  class Csi { public: int x; int ; static Csi static_member; };

If 'static_member' is missing its static bit then the value printer
will go into a recursive loop printing the members of static_member.

I grepped a bit and I don't think any other debug readers have this bug.
If they do, the test suite will blow up on the "print static member"
test.

Testing: I ran the test suite on native hppa2.0w-hp-hpux11.11, hp-ux aCC.

The MAINTAINERS file says:

  HP/UX readers		Any [past] maintainer can modify this.
			Please send tricky ones to the symtabs maintainers.

Woo hoo, I am authorized!

I am committing this now.

Michael C

2004-01-07  Michael Chastain  <mec.gnu@mindspring.com>

	* hpread.c (hpread_read_struct_type): Call SET_FIELD_PHYSNAME
	properly for static fields.

Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.41
diff -c -3 -p -r1.41 hpread.c
*** hpread.c	23 Nov 2003 20:41:16 -0000	1.41
--- hpread.c	7 Jan 2004 11:17:21 -0000
***************
*** 1,6 ****
  /* Read hp debug symbols and convert to internal format, for GDB.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
!    Free Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,6 ----
  /* Read hp debug symbols and convert to internal format, for GDB.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
!    2002, 2003, 2004 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** hpread_read_struct_type (dnttpointer hp_
*** 4160,4175 ****
  	  list->field.name = VT (objfile) + fieldp->dfield.name;
  
  
! 	  /* A FIELD by itself (without a GENFIELD) can also be a static member */
! 	  FIELD_STATIC_KIND (list->field) = 0;
  	  if (fieldp->dfield.staticmem)
  	    {
! 	      FIELD_BITPOS (list->field) = -1;
  	      FIELD_BITSIZE (list->field) = 0;
  	    }
  	  else
  	    /* Non-static data member */
  	    {
  	      FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset;
  	      if (fieldp->dfield.bitlength % 8)
  		FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength;
--- 4160,4178 ----
  	  list->field.name = VT (objfile) + fieldp->dfield.name;
  
  
! 	  /* A FIELD by itself (without a GENFIELD) can also be a static
! 	     member.  Mark it as static with a physname of NULL.
! 	     fix_static_member_physnames will assign the physname later. */
  	  if (fieldp->dfield.staticmem)
  	    {
! 	      SET_FIELD_PHYSNAME (list->field, NULL);
! 	      FIELD_BITPOS (list->field) = 0;
  	      FIELD_BITSIZE (list->field) = 0;
  	    }
  	  else
  	    /* Non-static data member */
  	    {
+ 	      FIELD_STATIC_KIND (list->field) = 0;
  	      FIELD_BITPOS (list->field) = fieldp->dfield.bitoffset;
  	      if (fieldp->dfield.bitlength % 8)
  		FIELD_BITSIZE (list->field) = fieldp->dfield.bitlength;



More information about the Gdb-patches mailing list