From: Daniel Jacobowitz <drow@mvista.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: gdb <gdb@sources.redhat.com>, Tom Tromey <tromey@redhat.com>,
Michael Elizabeth Chastain <mec@shout.net>
Subject: Re: break jmisc.main
Date: Thu, 13 Mar 2003 23:36:00 -0000 [thread overview]
Message-ID: <20030313233611.GA22688@nevyn.them.org> (raw)
In-Reply-To: <ro1of4ekflg.fsf@jackfruit.Stanford.EDU>
On Thu, Mar 13, 2003 at 03:32:27PM -0800, David Carlton wrote:
> On 13 Mar 2003 13:15:59 -0800, David Carlton <carlton@math.stanford.edu> said:
>
> > I'll think about this, but if there's no easy way to get a good
> > guess at the current language when building minimal symbol tables, I
> > suppose I'll reluctantly take a stab at the temporary solution.
>
> Actually, it wasn't so bad: Daniel did a good job of making the new
> symbol name initialization functions modular, so I only had to touch
> one of them. Here's a patch that might work; it doesn't cause any
> non-Java regressions, but this machine doesn't have gcj 3.2 on it, so
> I have no idea if it actually fixes the problem. I'll try to test it
> tonight when I get home, but if anybody reading this wants to test it
> before then, that would be great. The symtab.h part is purely
> cosmetic: just apply the symtab.c part, if you don't want to have to
> recompile every file that depends on symtab.h.
Hmm, I like this in principle. Could it have a more prominent FIXME on
it though? It's really not a good long term solution. We shouldn't
need both demangled copies... or if we do, then perhaps both should be
associated with the minsym.
>
> David Carlton
> carlton@math.stanford.edu
>
> 2003-03-13 David Carlton <carlton@math.stanford.edu>
>
> * symtab.c (symbol_set_names): Add prefix when storing Java names
> in hash table. Fix for PR java/1039.
> * 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 13 Mar 2003 22:59:00 -0000
> @@ -484,61 +484,103 @@ 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. */
> +
> +/* We have to be careful when dealing with Java names: when we run
> + into a Java minimal symbol, we don't know it's a Java symbol, so it
> + gets demangled as a C++ name. This is unfortunate, but there's not
> + much we can do about it: but when demangling partial symbols and
> + regular symbols, we'd better not reuse the wrong demangled name.
> + (See PR gdb/1039.) We solve this by putting a distinctive prefix
> + on Java names when storing them in the hash table. */
> +
> +#define JAVA_PREFIX "##JAVA$$"
> +#define JAVA_PREFIX_LEN 8
>
> 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;
> + /* A copy of the linkage name that might have a special Java prefix
> + added to it, for use when looking names up in the hash table. */
> + const char *lookup_name;
> + /* The length of lookup_name. */
> + int lookup_len;
>
> 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, unless we're in the Java case. */
> + if (gsymbol->language == language_java)
> {
> - char *alloc_name = alloca (len + 1);
> - memcpy (alloc_name, name, len);
> - alloc_name[len] = 0;
> - tmpname = alloc_name;
> + char *alloc_name;
> + lookup_len = len + JAVA_PREFIX_LEN;
> +
> + alloc_name = alloca (lookup_len + 1);
> + memcpy (alloc_name, JAVA_PREFIX, JAVA_PREFIX_LEN);
> + memcpy (alloc_name + JAVA_PREFIX_LEN, linkage_name, len);
> + alloc_name[lookup_len] = '\0';
> +
> + lookup_name = alloc_name;
> + linkage_name_copy = alloc_name + JAVA_PREFIX_LEN;
> + }
> + else if (linkage_name[len] != '\0')
> + {
> + char *alloc_name;
> + lookup_len = len;
> +
> + alloc_name = alloca (lookup_len + 1);
> + memcpy (alloc_name, linkage_name, len);
> + alloc_name[lookup_len] = '\0';
> +
> + lookup_name = alloc_name;
> + linkage_name_copy = alloc_name;
> }
> else
> - tmpname = name;
> + {
> + lookup_len = len;
> + lookup_name = linkage_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,
> + lookup_name, 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.
> Otherwise, just place a second zero byte after the end of the mangled
> name. */
> *slot = obstack_alloc (&objfile->symbol_obstack,
> - len + demangled_len + 2);
> - memcpy (*slot, tmpname, len + 1);
> - if (demangled_name)
> + lookup_len + demangled_len + 2);
> + memcpy (*slot, lookup_name, lookup_len + 1);
> + if (demangled_name != NULL)
> {
> - memcpy (*slot + len + 1, demangled_name, demangled_len + 1);
> + memcpy (*slot + lookup_len + 1, demangled_name, demangled_len + 1);
> xfree (demangled_name);
> }
> else
> - (*slot)[len + 1] = 0;
> + (*slot)[lookup_len + 1] = '\0';
> }
>
> - gsymbol->name = *slot;
> - if ((*slot)[len + 1])
> + gsymbol->name = *slot + lookup_len - len;
> + if ((*slot)[lookup_len + 1] != '\0')
> gsymbol->language_specific.cplus_specific.demangled_name
> - = &(*slot)[len + 1];
> + = &(*slot)[lookup_len + 1];
> else
> gsymbol->language_specific.cplus_specific.demangled_name = NULL;
> }
> Index: symtab.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.h,v
> retrieving revision 1.65
> diff -u -p -r1.65 symtab.h
> --- symtab.h 3 Mar 2003 18:34:12 -0000 1.65
> +++ symtab.h 13 Mar 2003 22:59:05 -0000
> @@ -156,10 +156,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
>
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2003-03-13 23:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-13 20:39 David Carlton
2003-03-13 20:54 ` David Carlton
2003-03-13 20:57 ` Daniel Jacobowitz
2003-03-13 21:07 ` Daniel Jacobowitz
2003-03-13 21:16 ` David Carlton
2003-03-13 21:22 ` Daniel Jacobowitz
2003-03-13 23:32 ` David Carlton
2003-03-13 23:36 ` Daniel Jacobowitz [this message]
2003-03-14 0:17 ` David Carlton
2003-03-14 4:18 ` Daniel Jacobowitz
2003-03-13 23:04 ` Tom Tromey
2003-03-13 22:59 ` Tom Tromey
2003-03-13 23:03 ` Daniel Jacobowitz
2003-03-14 15:09 Michael Elizabeth Chastain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030313233611.GA22688@nevyn.them.org \
--to=drow@mvista.com \
--cc=carlton@math.stanford.edu \
--cc=gdb@sources.redhat.com \
--cc=mec@shout.net \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox