🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #363

(none)

#363
From: Peggy Fieland
Date: Wed, 12 Aug 1992 19:32
130 lines
3793 bytes
FOr gdb-4.6 (On a Sun Sparc or Stratus FTX2 (i860)),
when demangling style is set to cfront, gdb does
not properly demangle member functions whose parameters
have the same type  -- but it is correct for these
types of functions when they are not member functions.

The problem is that cfront uses a one-based numbering scheme
for non-member function parameters , but a zero -based one
for member functions -- ie, it is necessary to know
if the function is a member function in order to properly
demangle it's parameters.

Here is a test program:

  class complex
      {
      double r;
      double i;
      public:
              complex(){};
              complex(double x,double y); 
          long funny_name_ (long l);

      };

long complex::funny_name_ (long l)
{
 return l;
}

 complex::complex(double x, double y)
{
r=x; 
i=y;

}
long plus (long l, long m)
{
 return (l + m);
}

main()
{

complex cc;

}

Here is a sample debugging session:
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) set demangle-style cfront
(gdb)  maintenance demangle __ct__7complexFdT1
complex::complex(double, complex)
(gdb) set print demangle off
(gdb) info functions plus
All functions matching regular expression "plus":

File complex.c:
int plus__FlT1();
(gdb) maintenance demangle plus__FlT1
plus(long, long)
(gdb) info functions complex
All functions matching regular expression "complex":

File complex.c:
struct complex *__ct__7complexFdT1();
int funny_name___7complexFl();
(gdb) q
 
Here is a fix:


*** /home/tools/gnu/gdb-4.6/gdb/cplus-dem.c	Tue Jul 14 03:34:20 1992
--- cplus-dem.c	Mon Aug 10 09:58:32 1992
***************
*** 57,67 ****
    int destructor;
    int static_type;	/* A static member function */
    int const_type;	/* A const member function */
  };
  
  #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
  #define PRINT_ARG_TYPES       (work -> options & DMGL_PARAMS)
! 
  static const struct optable
  {
    const char *in;
--- 61,72 ----
    int destructor;
    int static_type;	/* A static member function */
    int const_type;	/* A const member function */
+   int is_in_class; /* is a member function of a class */
  };
  
  #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
  #define PRINT_ARG_TYPES       (work -> options & DMGL_PARAMS)

  static const struct optable
  {
    const char *in;
***************
*** 465,470 ****
--- 473,479 ----
  	    if (success)
  	      {
  		remember_type (premangle, *mangled - premangle, work);
+           work -> is_in_class = 1;
  	      }
  #endif
  	    if (current_demangling_style == auto_demangling ||
***************
*** 1585,1591 ****
  	      return (0);
  	    }
  	  if (current_demangling_style == lucid_demangling ||
! 	      current_demangling_style == cfront_demangling)
  	    {
  	      t--;
  	    }
--- 1693,1699 ----
  	      return (0);
  	    }
  	  if (current_demangling_style == lucid_demangling ||
! 	      ((current_demangling_style == cfront_demangling) && (work -> is_in_class== 0)))
  	    {
  	      t--;
  	    }
Technical Details
Message-ID: <9208121932.AA10290@cyclonic.sw.stratus.com.sw.stratus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cyclonic.sw.stratus.com!pfieland

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cyclonic.sw.stratus.com!pfieland
From: pfieland@cyclonic.sw.stratus.com (Peggy Fieland)
Subject: (none)
Message-ID: <9208121932.AA10290@cyclonic.sw.stratus.com.sw.stratus.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 12 Aug 1992 19:32:15 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 132