public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* patch for c++filt
@ 1999-07-01  0:00 Jim Blandy
  1999-07-01  0:00 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 1999-07-01  0:00 UTC (permalink / raw)
  To: binutils

This patch is meant to solve a problem reported by Joe Buck back in
February, and forwarded by Jeff Law to the GDB group.

If you think this change is overkill, I have a milder approach in mind
(simply adding an (current_demangling_style == hp_demangling) to the
big hairy `if' condition in main), which I would be happy to prepare
an alternative patch to implement.

binutils/libiberty/ChangeLog:

1999-05-11  Jim Blandy  <jimb@zwingli.cygnus.com>

	* cplus-dem.c (main): Use table lookup to distinguish identifier
	characters from non-identifier characters.
	(standard_symbol_alphabet, hp_symbol_alphabet): New functions.

Index: cplus-dem.c
===================================================================
RCS file: /cvs/binutils/binutils/libiberty/cplus-dem.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 cplus-dem.c
*** cplus-dem.c	1999/05/03 07:28:54	1.1.1.1
--- cplus-dem.c	1999/05/11 16:18:09
***************
*** 4379,4384 ****
--- 4379,4444 ----
    fatal ("Internal gcc abort.");
  }
  
+ 
+ /* Fill in TABLE so that TABLE[C] is true iff C (as an unsigned char)
+    is a valid symbol component, in the standard assembler symbol
+    syntax.  */
+ void
+ standard_symbol_alphabet (char *table)
+ {
+   int c;
+ 
+   for (c = 0; c < 256; c++)
+     table[c] = isalnum(c);
+ 
+   table['_'] = 1;
+   table['$'] = 1;
+   table['.'] = 1;
+ }
+ 
+ 
+ /* Fill in TABLE so that TABLE[C] is true iff C (as an unsigned char)
+    is a valid symbol name component in an HP object file.
+ 
+    Note that, since HP's compiler generates object code straight from
+    C++ source, without going through an assembler, its mangled
+    identifiers can use all sorts of characters that no assembler would
+    tolerate, so the alphabet this function creates is a little odd.
+    Here are some sample mangled identifiers offered by HP:
+ 
+ 	typeid*__XT24AddressIndExpClassMember_
+ 	[Vftptr]key:__dt__32OrdinaryCompareIndExpClassMemberFv
+ 	__ct__Q2_9Elf64_Dyn18{unnamed.union.#1}Fv
+ 
+    This still seems really weird to me, since nowhere else in this
+    file is there anything to recognize curly brackets, parens, etc.
+    I've talked with Srikanth <srikanth@cup.hp.com>, and he assures me
+    this is right, but I still strongly suspect that there's a
+    misunderstanding here.
+ 
+    If we decide it's better for c++filt to use HP's assembler syntax
+    to scrape identifiers out of its input, here's the definition of
+    the symbol name syntax from the HP assembler manual:
+ 
+        Symbols are composed of uppercase and lowercase letters, decimal
+        digits, dollar symbol, period (.), ampersand (&), pound sign(#) and
+        underscore (_). A symbol can begin with a letter, digit underscore or
+        dollar sign. If a symbol begins with a digit, it must contain a
+        non-digit character.
+ 
+    So have fun.  */
+ void
+ hp_symbol_alphabet (char *table)
+ {
+   char *c;
+ 
+   standard_symbol_alphabet (table);
+ 
+   for (c = "<>#,*&[]:(){}"; *c; c++)
+     table[(unsigned char) *c] = 1;
+ }
+ 
+ 
  int
  main (argc, argv)
       int argc;
***************
*** 4386,4391 ****
--- 4446,4452 ----
  {
    char *result;
    int c;
+   char symbol_alphabet[256];
  
    program_name = argv[0];
  
***************
*** 4452,4467 ****
      }
    else
      {
        for (;;)
  	{
  	  int i = 0;
  	  c = getchar ();
  	  /* Try to read a label.  */
! 	  while (c != EOF && (isalnum(c) || c == '_' || c == '$' || c == '.' ||
!                               c == '<' || c == '>' || c == '#' || c == ',' || c == '*' || c == '&' ||
!                               c == '[' || c == ']' || c == ':' || c == '(' || c == ')'))
!                               /* the ones in the 2nd & 3rd lines were added to handle
!                                  HP aCC template specialization manglings */
  	    {
  	      if (i >= MBUF_SIZE-1)
  		break;
--- 4513,4542 ----
      }
    else
      {
+       switch (current_demangling_style)
+ 	{
+ 	case gnu_demangling:
+ 	case lucid_demangling:
+ 	case arm_demangling:
+ 	case edg_demangling:
+ 	  standard_symbol_alphabet (symbol_alphabet);
+ 	  break;
+ 	case hp_demangling:
+ 	  hp_symbol_alphabet (symbol_alphabet);
+ 	  break;
+ 	default:
+ 	  /* Folks should explicitly indicate the appropriate alphabet for
+ 	     each demangling.  Providing a default would allow the
+ 	     question to go unconsidered.  */
+ 	  abort ();
+ 	}
+ 
        for (;;)
  	{
  	  int i = 0;
  	  c = getchar ();
  	  /* Try to read a label.  */
! 	  while (c != EOF && symbol_alphabet[c])
  	    {
  	      if (i >= MBUF_SIZE-1)
  		break;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch for c++filt
  1999-07-01  0:00 patch for c++filt Jim Blandy
@ 1999-07-01  0:00 ` Ian Lance Taylor
  1999-07-01  0:00   ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 1999-07-01  0:00 UTC (permalink / raw)
  To: jimb; +Cc: binutils

   Date: Tue, 11 May 1999 11:20:40 -0500 (EST)
   From: Jim Blandy <jimb@cygnus.com>

   This patch is meant to solve a problem reported by Joe Buck back in
   February, and forwarded by Jeff Law to the GDB group.

   If you think this change is overkill, I have a milder approach in mind
   (simply adding an (current_demangling_style == hp_demangling) to the
   big hairy `if' condition in main), which I would be happy to prepare
   an alternative patch to implement.

cplus-dem.c is really maintained by the gcc/egcs g++ team.  I
routinely forward patches to them for approval.  If they approve it,
it goes into the egcs tree, then migrates into the Cygnus tree and
(now) into the binutils tree.

(The binutils tree used to be the same as the Cygnus tree.  We may now
want to develop some regular merge from the egcs libiberty into the
binutils libiberty.)

Anyhow, if your patch is in egcs, go ahead and check it into the
binutils.  Otherwise, get it into egcs first, and then check it in
here.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch for c++filt
  1999-07-01  0:00 ` Ian Lance Taylor
@ 1999-07-01  0:00   ` Jim Blandy
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Blandy @ 1999-07-01  0:00 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

> Anyhow, if your patch is in egcs, go ahead and check it into the
> binutils.  Otherwise, get it into egcs first, and then check it in
> here.

It was approved for EGCS, so I've committed it to binutils, too.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-07-01  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-01  0:00 patch for c++filt Jim Blandy
1999-07-01  0:00 ` Ian Lance Taylor
1999-07-01  0:00   ` Jim Blandy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).