From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8700 invoked by alias); 14 Apr 2003 19:59:20 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 8692 invoked from network); 14 Apr 2003 19:59:19 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by sources.redhat.com with SMTP; 14 Apr 2003 19:59:19 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h3EJxCj21510; Mon, 14 Apr 2003 12:59:12 -0700 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: Elena Zannoni Cc: gdb-patches@sources.redhat.com, Jim Blandy Subject: Re: [rfa] fix pr java/1039 References: <16026.62985.154698.757346@localhost.redhat.com> From: David Carlton Date: Mon, 14 Apr 2003 19:59:00 -0000 In-Reply-To: <16026.62985.154698.757346@localhost.redhat.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg00292.txt.bz2 On Mon, 14 Apr 2003 13:55:21 -0400, Elena Zannoni said: > could you do it in 2 passes? First pass with the format changes and > the variables renaming. Second pass with the actual juicy Java > fixes. Good idea; I've committed it as you suggest. Here's the first patch, that only renames things and tidies up the format a bit; I'll send the second patch in a sec. David Carlton carlton@math.stanford.edu 2003-04-14 David Carlton * symtab.c (symbol_set_names): Rename 'name' arg to 'linkage_name', and 'tmpname' variable to 'linkage_name_copy'. * symtab.h: Change 'name' argument in declaration of symbol_set_names to 'linkage_name'. (SYMBOL_SET_NAMES): Change 'name' argument to 'linkage_name'. Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.99 diff -u -p -r1.99 symtab.c --- symtab.c 4 Mar 2003 17:06:21 -0000 1.99 +++ symtab.c 14 Apr 2003 19:28:32 -0000 @@ -484,40 +484,49 @@ symbol_find_demangled_name (struct gener return NULL; } -/* Set both the mangled and demangled (if any) names for GSYMBOL based on - NAME and LEN. The hash table corresponding to OBJFILE is used, and the - memory comes from that objfile's symbol_obstack. NAME is copied, so the - pointer can be discarded after calling this function. */ +/* Set both the mangled and demangled (if any) names for GSYMBOL based + on LINKAGE_NAME and LEN. The hash table corresponding to OBJFILE + is used, and the memory comes from that objfile's symbol_obstack. + LINKAGE_NAME is copied, so the pointer can be discarded after + calling this function. */ void symbol_set_names (struct general_symbol_info *gsymbol, - const char *name, int len, struct objfile *objfile) + const char *linkage_name, int len, struct objfile *objfile) { char **slot; - const char *tmpname; + /* A 0-terminated copy of the linkage name. */ + const char *linkage_name_copy; if (objfile->demangled_names_hash == NULL) create_demangled_names_hash (objfile); - /* The stabs reader generally provides names that are not NULL-terminated; - most of the other readers don't do this, so we can just use the given - copy. */ - if (name[len] != 0) + /* The stabs reader generally provides names that are not + NUL-terminated; most of the other readers don't do this, so we + can just use the given copy. */ + if (linkage_name[len] != '\0') { - char *alloc_name = alloca (len + 1); - memcpy (alloc_name, name, len); - alloc_name[len] = 0; - tmpname = alloc_name; + char *alloc_name; + + alloc_name = alloca (len + 1); + memcpy (alloc_name, linkage_name, len); + alloc_name[len] = '\0'; + + linkage_name_copy = alloc_name; } else - tmpname = name; + { + linkage_name_copy = linkage_name; + } - slot = (char **) htab_find_slot (objfile->demangled_names_hash, tmpname, INSERT); + slot = (char **) htab_find_slot (objfile->demangled_names_hash, + linkage_name_copy, INSERT); /* If this name is not in the hash table, add it. */ if (*slot == NULL) { - char *demangled_name = symbol_find_demangled_name (gsymbol, tmpname); + char *demangled_name = symbol_find_demangled_name (gsymbol, + linkage_name_copy); int demangled_len = demangled_name ? strlen (demangled_name) : 0; /* If there is a demangled name, place it right after the mangled name. @@ -525,18 +534,18 @@ symbol_set_names (struct general_symbol_ name. */ *slot = obstack_alloc (&objfile->symbol_obstack, len + demangled_len + 2); - memcpy (*slot, tmpname, len + 1); - if (demangled_name) + memcpy (*slot, linkage_name_copy, len + 1); + if (demangled_name != NULL) { memcpy (*slot + len + 1, demangled_name, demangled_len + 1); xfree (demangled_name); } else - (*slot)[len + 1] = 0; + (*slot)[len + 1] = '\0'; } gsymbol->name = *slot; - if ((*slot)[len + 1]) + if ((*slot)[len + 1] != '\0') gsymbol->language_specific.cplus_specific.demangled_name = &(*slot)[len + 1]; else Index: symtab.h =================================================================== RCS file: /cvs/src/src/gdb/symtab.h,v retrieving revision 1.66 diff -u -p -r1.66 symtab.h --- symtab.h 12 Apr 2003 17:41:26 -0000 1.66 +++ symtab.h 14 Apr 2003 19:28:23 -0000 @@ -158,10 +158,10 @@ extern void symbol_init_language_specifi extern void symbol_init_demangled_name (struct general_symbol_info *symbol, struct obstack *obstack); -#define SYMBOL_SET_NAMES(symbol,name,len,objfile) \ - symbol_set_names (&(symbol)->ginfo, name, len, objfile) +#define SYMBOL_SET_NAMES(symbol,linkage_name,len,objfile) \ + symbol_set_names (&(symbol)->ginfo, linkage_name, len, objfile) extern void symbol_set_names (struct general_symbol_info *symbol, - const char *name, int len, + const char *linkage_name, int len, struct objfile *objfile); /* Now come lots of name accessor macros. Short version as to when to