home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / gnu / gdb / bug / 965 < prev    next >
Encoding:
Text File  |  1992-08-12  |  3.6 KB  |  145 lines

  1. Newsgroups: gnu.gdb.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!cyclonic.sw.stratus.com!pfieland
  3. From: pfieland@cyclonic.sw.stratus.com (Peggy Fieland)
  4. Subject: (none)
  5. Message-ID: <9208121932.AA10290@cyclonic.sw.stratus.com.sw.stratus.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 12 Aug 1992 19:32:15 GMT
  10. Approved: bug-gdb@prep.ai.mit.edu
  11. Lines: 132
  12.  
  13. FOr gdb-4.6 (On a Sun Sparc or Stratus FTX2 (i860)),
  14. when demangling style is set to cfront, gdb does
  15. not properly demangle member functions whose parameters
  16. have the same type  -- but it is correct for these
  17. types of functions when they are not member functions.
  18.  
  19. The problem is that cfront uses a one-based numbering scheme
  20. for non-member function parameters , but a zero -based one
  21. for member functions -- ie, it is necessary to know
  22. if the function is a member function in order to properly
  23. demangle it's parameters.
  24.  
  25. Here is a test program:
  26.  
  27.   class complex
  28.       {
  29.       double r;
  30.       double i;
  31.       public:
  32.               complex(){};
  33.               complex(double x,double y); 
  34.           long funny_name_ (long l);
  35.  
  36.       };
  37.  
  38. long complex::funny_name_ (long l)
  39. {
  40.  return l;
  41. }
  42.  
  43.  complex::complex(double x, double y)
  44. {
  45. r=x; 
  46. i=y;
  47.  
  48. }
  49. long plus (long l, long m)
  50. {
  51.  return (l + m);
  52. }
  53.  
  54. main()
  55. {
  56.  
  57. complex cc;
  58.  
  59. }
  60.  
  61. Here is a sample debugging session:
  62. GDB is free software and you are welcome to distribute copies of it
  63.  under certain conditions; type "show copying" to see the conditions.
  64. There is absolutely no warranty for GDB; type "show warranty" for details.
  65. GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
  66. (gdb) set demangle-style cfront
  67. (gdb)  maintenance demangle __ct__7complexFdT1
  68. complex::complex(double, complex)
  69. (gdb) set print demangle off
  70. (gdb) info functions plus
  71. All functions matching regular expression "plus":
  72.  
  73. File complex.c:
  74. int plus__FlT1();
  75. (gdb) maintenance demangle plus__FlT1
  76. plus(long, long)
  77. (gdb) info functions complex
  78. All functions matching regular expression "complex":
  79.  
  80. File complex.c:
  81. struct complex *__ct__7complexFdT1();
  82. int funny_name___7complexFl();
  83. (gdb) q
  84.  
  85. Here is a fix:
  86.  
  87.  
  88. *** /home/tools/gnu/gdb-4.6/gdb/cplus-dem.c    Tue Jul 14 03:34:20 1992
  89. --- cplus-dem.c    Mon Aug 10 09:58:32 1992
  90. ***************
  91. *** 57,67 ****
  92.     int destructor;
  93.     int static_type;    /* A static member function */
  94.     int const_type;    /* A const member function */
  95.   };
  96.   
  97.   #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
  98.   #define PRINT_ARG_TYPES       (work -> options & DMGL_PARAMS)
  99.   static const struct optable
  100.   {
  101.     const char *in;
  102. --- 61,72 ----
  103.     int destructor;
  104.     int static_type;    /* A static member function */
  105.     int const_type;    /* A const member function */
  106. +   int is_in_class; /* is a member function of a class */
  107.   };
  108.   
  109.   #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
  110.   #define PRINT_ARG_TYPES       (work -> options & DMGL_PARAMS)
  111.  
  112.   static const struct optable
  113.   {
  114.     const char *in;
  115. ***************
  116. *** 465,470 ****
  117. --- 473,479 ----
  118.           if (success)
  119.             {
  120.           remember_type (premangle, *mangled - premangle, work);
  121. +           work -> is_in_class = 1;
  122.             }
  123.   #endif
  124.           if (current_demangling_style == auto_demangling ||
  125. ***************
  126. *** 1585,1591 ****
  127.             return (0);
  128.           }
  129.         if (current_demangling_style == lucid_demangling ||
  130. !           current_demangling_style == cfront_demangling)
  131.           {
  132.             t--;
  133.           }
  134. --- 1693,1699 ----
  135.             return (0);
  136.           }
  137.         if (current_demangling_style == lucid_demangling ||
  138. !           ((current_demangling_style == cfront_demangling) && (work -> is_in_class== 0)))
  139.           {
  140.             t--;
  141.           }
  142.  
  143.  
  144.