This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Step down from maintainerships
Jim Blandy <jimb@redhat.com> writes:
> - Demangling language needs to be stored in demangled name cache,
> along with demangled name:
>
> http://sources.redhat.com/ml/gdb-patches/2004-08/msg00479.html
>
> The patch proposed there would undo prior optimizations, which I
> explain here:
>
> http://sources.redhat.com/ml/gdb-patches/2004-09/msg00263.html
>
> (That message is not part of the same thread, since it's in a
> different month, so don't miss it.)
For what it's worth, I have a tentative patch for this. It's not
tested, but it could be a starting point. (Ton van Overbeek
originally reported the problem, and has offered to test patches.)
2004-10-19 Jim Blandy <jimb@redhat.com>
* symtab.c (symbol_set_names): Store the demangling language, as
well as the demangled name, in the demangling cache. Use it to
set the language on symbols whose names we find in the cache.
* objfiles.h (struct objfile): Doc fix.
Index: gdb/objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.39
diff -c -p -r1.39 objfiles.h
*** gdb/objfiles.h 2 Sep 2004 03:05:46 -0000 1.39
--- gdb/objfiles.h 19 Oct 2004 19:23:20 -0000
*************** struct objfile
*** 267,275 ****
/* Hash table for mapping symbol names to demangled names. Each
entry in the hash table is actually two consecutive strings,
! both null-terminated; the first one is a mangled or linkage
! name, and the second is the demangled name or just a zero byte
! if the name doesn't demangle. */
struct htab *demangled_names_hash;
/* Vectors of all partial symbols read in from file. The actual data
--- 267,280 ----
/* Hash table for mapping symbol names to demangled names. Each
entry in the hash table is actually two consecutive strings,
! both null-terminated, possibly followed by a byte:
! - the first string is a mangled or linkage name,
! - the second string is the demangled name, or just a zero byte
! if the name doesn't demangle, and
! - if the demangled name is non-empty, the byte after the second
! null character is the 'enum language' value for the
! demangling regimen we used. If the demangled name is empty,
! the byte is absent. */
struct htab *demangled_names_hash;
/* Vectors of all partial symbols read in from file. The actual data
Index: gdb/symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.140
diff -c -p -r1.140 symtab.c
*** gdb/symtab.c 2 Oct 2004 09:55:15 -0000 1.140
--- gdb/symtab.c 19 Oct 2004 19:23:21 -0000
*************** symbol_set_names (struct general_symbol_
*** 576,598 ****
Otherwise, just place a second zero byte after the end of the mangled
name. */
*slot = obstack_alloc (&objfile->objfile_obstack,
! lookup_len + demangled_len + 2);
memcpy (*slot, lookup_name, lookup_len + 1);
if (demangled_name != NULL)
{
memcpy (*slot + lookup_len + 1, demangled_name, demangled_len + 1);
xfree (demangled_name);
}
else
(*slot)[lookup_len + 1] = '\0';
}
gsymbol->name = *slot + lookup_len - len;
! if ((*slot)[lookup_len + 1] != '\0')
! gsymbol->language_specific.cplus_specific.demangled_name
! = &(*slot)[lookup_len + 1];
! else
! gsymbol->language_specific.cplus_specific.demangled_name = NULL;
}
/* Initialize the demangled name of GSYMBOL if possible. Any required space
--- 576,624 ----
Otherwise, just place a second zero byte after the end of the mangled
name. */
*slot = obstack_alloc (&objfile->objfile_obstack,
! lookup_len + 1 + demangled_len + 1 + 1);
memcpy (*slot, lookup_name, lookup_len + 1);
if (demangled_name != NULL)
{
memcpy (*slot + lookup_len + 1, demangled_name, demangled_len + 1);
xfree (demangled_name);
+ /* Record the language we used to demangle the name, too. */
+ (*slot)[lookup_len + 1 + demangled_len + 1] = gsymbol->language;
}
else
(*slot)[lookup_len + 1] = '\0';
}
+ else
+ {
+ /* This is what symbol_find_demangled_name does when we don't
+ find a hash table entry, so we should do it when we do find
+ one as well. */
+ if (gsymbol->language == language_unknown)
+ gsymbol->language = language_auto;
+ }
+ /* At this point we've definitely got a hash table entry, whether
+ prexisting or just created. Make gsymbol share its name with
+ the hash table entry. */
gsymbol->name = *slot + lookup_len - len;
!
! /* Share the demangled name as well, if there is one. */
! {
! char *demangled_name = *slot + lookup_len + 1;
!
! if (demangled_name != '\0')
! {
! size_t demangled_len = strlen (demangled_name);
!
! gsymbol->language_specific.cplus_specific.demangled_name
! = demangled_name;
!
! /* Set gsymbol's language from the byte after the demangled name. */
! gsymbol->language = (enum language) demangled_name[demangled_len + 1];
! }
! else
! gsymbol->language_specific.cplus_specific.demangled_name = NULL;
! }
}
/* Initialize the demangled name of GSYMBOL if possible. Any required space