home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / g / help / 1483 < prev    next >
Encoding:
Internet Message Format  |  1992-11-24  |  4.3 KB

  1. Xref: sparky gnu.g++.help:1483 comp.lang.c++:16824
  2. Path: sparky!uunet!kithrup!hoptoad!brendan
  3. From: brendan@cygnus.com (Brendan Kehoe)
  4. Newsgroups: gnu.g++.help,comp.lang.c++
  5. Subject: Re: demangeling
  6. Message-ID: <39219@hoptoad.uucp>
  7. Date: 24 Nov 92 03:50:38 GMT
  8. References: <9211231128.AA20601@life.ai.mit.edu>
  9. Sender: news@hoptoad.uucp
  10. Reply-To: brendan@cygnus.com (Brendan Kehoe)
  11. Organization: Cygnus Support, Mountain View CA; Phone +1 415 903 1400
  12. Lines: 158
  13. Nntp-Posting-Host: cygnus.com
  14. In-reply-to: FLEINERC%CFRUNI51.BITNET@mitvma.mit.edu's message of 23 Nov 92 08:06:00 GMT
  15.  
  16. In article <9211231128.AA20601@life.ai.mit.edu> FLEINERC%CFRUNI51.BITNET@mitvma.mit.edu writes:
  17.  
  18.    Does there exist a program to demangle names used by C++ ?
  19.    it should accept for example
  20.     __ct__7ostreamFv
  21.    and print
  22.     ostream::ostream()
  23.  
  24.    If not, is someone writting such a beast ?
  25.  
  26. There is, in the libiberty directory of gdb-4.7.  It might be a good
  27. thing to include in the 2.4 release of gcc/g++; we'll see.
  28.  
  29. The next release of gdb will have a demangler that you can build
  30. easily (the stuff in 4.7 has some trouble); in the meantime, apply
  31. these diffs in the libiberty directory to be able to just do
  32.  
  33.     ../configure __whatever__
  34.     make demangle
  35.  
  36. and have it generate the program properly.
  37.  
  38.  
  39. *** Makefile.in.~1~    Thu Nov 19 03:12:13 1992
  40. --- Makefile.in    Thu Nov 19 03:58:24 1992
  41. ***************
  42. *** 218,224 ****
  43.   # Create a standalone demangler if so desired ("make demangle").
  44.   
  45. ! demangle: ${srcdir}/${DEMANGLER}.c
  46. !     ${CC} -o $@ -DMAIN ${INTERNAL_CFLAGS} \
  47. !       `echo ${srcdir}/${DEMANGLER}.c | sed 's,^\./,,'`
  48.   
  49.   ls:
  50. --- 218,224 ----
  51.   # Create a standalone demangler if so desired ("make demangle").
  52.   
  53. ! demangle: ${srcdir}/cplus-dem.c
  54. !     $(CC) -o $@ -DMAIN $(CFLAGS) -I. -I$(srcdir)/../include $(HDEFINES) $(XTRAFLAGS) \
  55. !       `echo $^ | sed 's,^\./,,'`
  56.   
  57.   ls:
  58. *** cplus-dem.c.~1~    Tue Oct  6 11:18:33 1992
  59. --- cplus-dem.c    Thu Nov 19 03:58:27 1992
  60. ***************
  61. *** 35,38 ****
  62. --- 35,41 ----
  63.   #include <stdio.h>
  64.   
  65. + extern char *xmalloc ();
  66. + extern char *xrealloc ();
  67.   /* In order to allow a single demangler executable to demangle strings
  68.      using various common values of CPLUS_MARKER, as well as any specific
  69. *************** remember_type (work, start, len)
  70. *** 1720,1724 ****
  71.       }
  72.       }
  73. !   tem = (char *) xmalloc (len + 1);
  74.     memcpy (tem, start, len);
  75.     tem[len] = '\0';
  76. --- 1729,1733 ----
  77.       }
  78.       }
  79. !   tem = xmalloc (len + 1);
  80.     memcpy (tem, start, len);
  81.     tem[len] = '\0';
  82. *************** string_need (s, n)
  83. *** 2061,2065 ****
  84.         n = 32;
  85.       }
  86. !       s->p = s->b = (char *) xmalloc (n);
  87.         s->e = s->b + n;
  88.       }
  89. --- 2070,2074 ----
  90.         n = 32;
  91.       }
  92. !       s->p = s->b = xmalloc (n);
  93.         s->e = s->b + n;
  94.       }
  95. *************** string_need (s, n)
  96. *** 2069,2073 ****
  97.         n += tem;
  98.         n *= 2;
  99. !       s->b = (char *) xrealloc (s->b, n);
  100.         s->p = s->b + tem;
  101.         s->e = s->b + n;
  102. --- 2078,2082 ----
  103.         n += tem;
  104.         n *= 2;
  105. !       s->b = xrealloc (s->b, n);
  106.         s->p = s->b + tem;
  107.         s->e = s->b + n;
  108. *************** demangle_it (mangled_name)
  109. *** 2223,2233 ****
  110.   }
  111.   
  112. ! PTR
  113.   xmalloc (size)
  114.       long size;
  115.   {
  116. !   PTR newmem;
  117.   
  118. !   if ((newmem = malloc ((int) size)) == NULL)
  119.       {
  120.         fprintf (stderr, "\nCan't allocate %u bytes\n", size);
  121. --- 2232,2242 ----
  122.   }
  123.   
  124. ! char *
  125.   xmalloc (size)
  126.       long size;
  127.   {
  128. !   char * newmem;
  129.   
  130. !   if ((newmem = (char *) malloc ((int) size)) == NULL)
  131.       {
  132.         fprintf (stderr, "\nCan't allocate %u bytes\n", size);
  133. *************** xmalloc (size)
  134. *** 2237,2248 ****
  135.   }
  136.   
  137. ! PTR
  138.   xrealloc (oldmem, size)
  139. !     PTR oldmem;
  140.       long size;
  141.   {
  142. !   PTR newmem;
  143.   
  144. !   if ((newmem = realloc ((char *) oldmem, (int) size)) == NULL)
  145.       {
  146.         fprintf (stderr, "\nCan't reallocate %u bytes\n", size);
  147. --- 2246,2257 ----
  148.   }
  149.   
  150. ! char *
  151.   xrealloc (oldmem, size)
  152. !     char * oldmem;
  153.       long size;
  154.   {
  155. !   char * newmem;
  156.   
  157. !   if ((newmem = (char *) realloc ((char *) oldmem, (int) size)) == NULL)
  158.       {
  159.         fprintf (stderr, "\nCan't reallocate %u bytes\n", size);
  160. *************** main (argc, argv)
  161. *** 2307,2310 ****
  162. --- 2316,2321 ----
  163.       }
  164.       }
  165. +   exit (0);
  166.   }
  167.   
  168.  
  169. --
  170. Brendan Kehoe                                               brendan@cygnus.com
  171. Cygnus Support, Mountain View, CA                              +1 415 903 1400
  172.