This is the mail archive of the gdb@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 BUG: No progress on PR/512 submitted 4/29/02


Posting as requested by Andrew Cagney...
--- Begin Message ---
Please post this to gdb@sources.redhat.com.

Andrew
--- Begin Message ---
Andrew, Stan,

I just wanted to "ping" you guys on a bug report submitted by my
colleague Stewart Brown to fix a bug that I found with GDB 5.0 back in
April 2002.

I think this bug needs to be fixed ASAP, because what good is a debugger
if it reports the wrong data type for a variable or a function, after
all?

For your reference, here is an excerpt from PR 512 submitted by Stewart
...

-----------------------
ptype command outputs wrong type when type is a typedef *.  For example
with the code:

typedef char* CHAR;
typedef CHAR* CHAR2;

the gdb command 'ptype CHAR' correctly reports char*, but 'ptype CHAR2'
reports
char *.  This is incorrect, as CHAR2 is actually a char**.

Another example:

typedef void (*fptr) (void);
typedef fptr* ptr;
fptr f;
ptr p;

the commands 'ptype f' and 'ptype fptr' both correctly return 'void
(*)(void)',
but the commands 'ptype ptr' and 'ptype p' both return 'void *', where
they
should return 'void (**)(void)'
---------------------------

Also attached is a patch created by Stewart that fixes this bug in GDB
5.0. My guess is that the patch should be applicable to GDB 5.2.1
without any problems...

Please make sure the credit for fixing this bug goes to Stewart Brown.

Thank you
- Bhavesh
-- 
Bhavesh P. Davda
Avaya Inc
Room B3-B03                     E-mail : bhavesh@avaya.com
1300 West 120th Avenue          Phone  : (303) 538-4438
Westminster, CO 80234           Fax    : (303) 538-3155
diff -cpr gdb.old/gdb/c-typeprint.c gdb.new/gdb/c-typeprint.c
*** gdb.old/gdb/c-typeprint.c	Mon Apr 29 09:36:56 2002
--- gdb.new/gdb/c-typeprint.c	Mon Apr 29 09:40:55 2002
*************** c_type_print_varspec_prefix (type, strea
*** 274,280 ****
    switch (TYPE_CODE (type))
      {
      case TYPE_CODE_PTR:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
        fprintf_filtered (stream, "*");
        c_type_print_cv_qualifier (type, stream, 1, 0);
        break;
--- 274,280 ----
    switch (TYPE_CODE (type))
      {
      case TYPE_CODE_PTR:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 1);
        fprintf_filtered (stream, "*");
        c_type_print_cv_qualifier (type, stream, 1, 0);
        break;
*************** c_type_print_varspec_prefix (type, strea
*** 282,288 ****
      case TYPE_CODE_MEMBER:
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
        fprintf_filtered (stream, " ");
        name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
        if (name)
--- 282,288 ----
      case TYPE_CODE_MEMBER:
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0);
        fprintf_filtered (stream, " ");
        name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
        if (name)
*************** c_type_print_varspec_prefix (type, strea
*** 295,301 ****
      case TYPE_CODE_METHOD:
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
        if (passed_a_ptr)
  	{
  	  fprintf_filtered (stream, " ");
--- 295,301 ----
      case TYPE_CODE_METHOD:
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0);
        if (passed_a_ptr)
  	{
  	  fprintf_filtered (stream, " ");
*************** c_type_print_varspec_prefix (type, strea
*** 305,327 ****
        break;
  
      case TYPE_CODE_REF:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
        fprintf_filtered (stream, "&");
        c_type_print_cv_qualifier (type, stream, 1, 0);
        break;
  
      case TYPE_CODE_FUNC:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
        break;
  
      case TYPE_CODE_ARRAY:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
        break;
  
      case TYPE_CODE_UNDEF:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
--- 305,331 ----
        break;
  
      case TYPE_CODE_REF:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 1);
        fprintf_filtered (stream, "&");
        c_type_print_cv_qualifier (type, stream, 1, 0);
        break;
  
      case TYPE_CODE_FUNC:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0);
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
        break;
  
      case TYPE_CODE_ARRAY:
!       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0);
        if (passed_a_ptr)
  	fprintf_filtered (stream, "(");
        break;
  
+     case TYPE_CODE_TYPEDEF:
+       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, show, 0);
+       break;
+ 
      case TYPE_CODE_UNDEF:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
*************** c_type_print_varspec_prefix (type, strea
*** 337,343 ****
      case TYPE_CODE_STRING:
      case TYPE_CODE_BITSTRING:
      case TYPE_CODE_COMPLEX:
-     case TYPE_CODE_TYPEDEF:
      case TYPE_CODE_TEMPLATE:
        /* These types need no prefix.  They are listed here so that
           gcc -Wall will reveal any types that haven't been handled.  */
--- 341,346 ----
*************** c_type_print_varspec_suffix (type, strea
*** 596,614 ****
  			   / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
        fprintf_filtered (stream, "]");
  
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
        break;
  
      case TYPE_CODE_MEMBER:
        if (passed_a_ptr)
  	fprintf_filtered (stream, ")");
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
        break;
  
      case TYPE_CODE_METHOD:
        if (passed_a_ptr)
  	fprintf_filtered (stream, ")");
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
        if (passed_a_ptr)
  	{
  	  c_type_print_args (type, stream);
--- 599,617 ----
  			   / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
        fprintf_filtered (stream, "]");
  
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
        break;
  
      case TYPE_CODE_MEMBER:
        if (passed_a_ptr)
  	fprintf_filtered (stream, ")");
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
        break;
  
      case TYPE_CODE_METHOD:
        if (passed_a_ptr)
  	fprintf_filtered (stream, ")");
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 0, 0);
        if (passed_a_ptr)
  	{
  	  c_type_print_args (type, stream);
*************** c_type_print_varspec_suffix (type, strea
*** 617,623 ****
  
      case TYPE_CODE_PTR:
      case TYPE_CODE_REF:
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
        break;
  
      case TYPE_CODE_FUNC:
--- 620,626 ----
  
      case TYPE_CODE_PTR:
      case TYPE_CODE_REF:
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show, 1, 0);
        break;
  
      case TYPE_CODE_FUNC:
*************** c_type_print_varspec_suffix (type, strea
*** 643,652 ****
  	      }
  	  fprintf_filtered (stream, ")");
  	}
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
  				   passed_a_ptr, 0);
        break;
  
      case TYPE_CODE_UNDEF:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
--- 646,660 ----
  	      }
  	  fprintf_filtered (stream, ")");
  	}
!       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
  				   passed_a_ptr, 0);
        break;
  
+     case TYPE_CODE_TYPEDEF:
+       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
+                                    passed_a_ptr, 0);
+ 	break;
+ 
      case TYPE_CODE_UNDEF:
      case TYPE_CODE_STRUCT:
      case TYPE_CODE_UNION:
*************** c_type_print_varspec_suffix (type, strea
*** 662,668 ****
      case TYPE_CODE_STRING:
      case TYPE_CODE_BITSTRING:
      case TYPE_CODE_COMPLEX:
-     case TYPE_CODE_TYPEDEF:
      case TYPE_CODE_TEMPLATE:
        /* These types do not need a suffix.  They are listed so that
           gcc -Wall will report types that may not have been considered.  */
--- 670,675 ----
--- End Message ---
--- End Message ---

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