Re: [RFA]: Fix partial symbol lookups

Peter.Schauer
2000-11-16T09:06:00Z

> No, I'll clean it up if you like. Assuming you don't want me to just
> revert all the 10-12 changes and be done with it.

This decision has to be made by the symtab maintainers of course.

> > No, it points out another problem with `maint check'. Have you ever tried it
> > with your patches ?
>
> Yes, I have.
> (gdb) maintenance check-symtabs
> During symbol reading, type qualifier 'const' ignored.
> During symbol reading, unsupported stack op: 'DW_OP_deref_size'.
> During symbol reading, type qualifier 'volatile' ignored.
> (gdb)

Well, with gcc-2.95.2 -ggdb on a linux x86 box I get

(gdb) maint check
During symbol reading, type qualifier 'const' ignored.
During symbol reading, type qualifier 'volatile' ignored.
During symbol reading, type qualifier 'const' ignored.
Global symbol `__24Contains_static_instanceii' only found in misc.cc psymtab
Global symbol `__31Contains_nested_static_instanceii' only found in misc.cc psym
tab
Global symbol `__3Bariii' only found in misc.cc psymtab
Global symbol `__3Fooii' only found in misc.cc psymtab
Global symbol `__5Base1i' only found in misc.cc psymtab
Global symbol `__Q231Contains_nested_static_instance6Nestedi' only found in misc
.cc psymtab
Global symbol `__opi__3Foo' only found in misc.cc psymtab
Global symbol `foo__C22const_vol_method_classRi' only found in misc.cc psymtab
Global symbol `times__3Fooi' only found in misc.cc psymtab

which is not surprising, because maintenance_check_symtabs calls
lookup_block_symbol with the mangled symbol name.
Perhaps you have applied more patches to your source tree...

--
Peter Schauer pes@regent.e-technik.tu-muenchen.de
From dberlin@redhat.com Thu Nov 16 09:16:00 2000
From: Daniel Berlin <dberlin@redhat.com>
To: gdb-patches@sources.redhat.com
Cc: Peter Schauer <Peter.Schauer@regent.e-technik.tu-muenchen.de>, jimb@redhat.com
Subject: [PATCH] revert 10-12 changes
Date: Thu, 16 Nov 2000 09:16:00 -0000
Message-id: <m3d7fv263i.fsf@dan2.cygnus.com>
X-SW-Source: 2000-11/msg00211.html
Content-length: 6925

Since these changes have been the bane of my existence, i'd like to
revert them.

Maybe in a few {weeks,months,years}, i'll make another go at it.

The attached should do this, but I left the division between
lookup_symbol and lookup_symbol_aux, since it seemed to make sense
(i'll revert this too if someone wants it the old way).

I also fixed the infinite recursion caused by this renaming, that Peter
had submitted a patch for.

Can someone look this over, and tell me if I missed anything? I went
by my submitted patch, but i've got a massive headache this morning,
so i may have missed something accidently.

--Dan

Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 symfile.c
*** symfile.c 2000/10/27 15:02:42 1.20
--- symfile.c 2000/11/16 17:06:36
*************** compare_symbols (const PTR s1p, const PT
*** 212,218 ****

s1 = (struct symbol **) s1p;
s2 = (struct symbol **) s2p;
! return (STRCMP (SYMBOL_SOURCE_NAME (*s1), SYMBOL_SOURCE_NAME (*s2)));
}

/*
--- 212,218 ----

s1 = (struct symbol **) s1p;
s2 = (struct symbol **) s2p;
! return (STRCMP (SYMBOL_NAME (*s1), SYMBOL_NAME (*s2)));
}

/*
*************** compare_psymbols (const PTR s1p, const P
*** 245,252 ****

s1 = (struct partial_symbol **) s1p;
s2 = (struct partial_symbol **) s2p;
! st1 = SYMBOL_SOURCE_NAME (*s1);
! st2 = SYMBOL_SOURCE_NAME (*s2);

if ((st1[0] - st2[0]) || !st1[0])
--- 245,252 ----

s1 = (struct partial_symbol **) s1p;
s2 = (struct partial_symbol **) s2p;
! st1 = SYMBOL_NAME (*s1);
! st2 = SYMBOL_NAME (*s2);

if ((st1[0] - st2[0]) || !st1[0])
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.22
diff -c -3 -p -r1.22 symtab.c
*** symtab.c 2000/11/10 23:02:56 1.22
--- symtab.c 2000/11/16 17:06:37
*************** lookup_symbol (const char *name, const s
*** 563,569 ****
{
char *modified_name = NULL;
char *modified_name2 = NULL;
- int needtofreename = 0;
struct symbol *returnval;

if (case_sensitivity == case_sensitive_off)
--- 563,568 ----
*************** lookup_symbol (const char *name, const s
*** 581,603 ****
else
modified_name = (char *) name;

- /* If we are using C++ language, demangle the name before doing a lookup, so
- we can always binary search. */
- if (current_language->la_language == language_cplus)
- {
- modified_name2 = cplus_demangle (modified_name, DMGL_ANSI | DMGL_PARAMS);
- if (modified_name2)
- {
- modified_name = modified_name2;
- needtofreename = 1;
- }
- }
-
returnval = lookup_symbol_aux (modified_name, block, namespace,
is_a_field_of_this, symtab);
- if (needtofreename)
- free (modified_name2);
-
return returnval;
}

--- 580,587 ----
*************** lookup_symbol_aux (const char *name, con
*** 772,778 ****
{
/* This is a mangled variable, look it up by its
mangled name. */
! return lookup_symbol (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);
}
/* There are no debug symbols for this file, or we are looking
--- 756,762 ----
{
/* This is a mangled variable, look it up by its
mangled name. */
! return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);
}
/* There are no debug symbols for this file, or we are looking
*************** lookup_symbol_aux (const char *name, con
*** 950,956 ****
&& MSYMBOL_TYPE (msymbol) != mst_file_text
&& !STREQ (name, SYMBOL_NAME (msymbol)))
{
! return lookup_symbol (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);
}
}
--- 934,940 ----
&& MSYMBOL_TYPE (msymbol) != mst_file_text
&& !STREQ (name, SYMBOL_NAME (msymbol)))
{
! return lookup_symbol_aux (SYMBOL_NAME (msymbol), block,
namespace, is_a_field_of_this, symtab);
}
}
*************** lookup_symbol_aux (const char *name, con
*** 964,971 ****
}

/* Look, in partial_symtab PST, for symbol NAME. Check the global
! symbols if GLOBAL, the static symbols if not */

static struct partial_symbol *
lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
namespace_enum namespace)
--- 948,960 ----
}

/* Look, in partial_symtab PST, for symbol NAME. Check the global
! symbols if GLOBAL, the static symbols if not.

+ Be aware that minimal symbols have no demangled names. So we need to lookup
+ by mangled name. However, this also means we can always binary search them,
+ since they are a sorted list. If you change the way partial symbols work,
+ you'll need to change this routine. */
+
static struct partial_symbol *
lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
namespace_enum namespace)
*************** lookup_partial_symbol (struct partial_sy
*** 1001,1011 ****
if (!(center < top))
abort ();
if (!do_linear_search
! && (SYMBOL_LANGUAGE (*center) == language_java))
{
do_linear_search = 1;
! }
! if (STRCMP (SYMBOL_SOURCE_NAME (*center), name) >= 0)
{
top = center;
}
--- 990,1002 ----
if (!(center < top))
abort ();
if (!do_linear_search
! && (SYMBOL_LANGUAGE (*center) == language_cplus
! || SYMBOL_LANGUAGE (*center) == language_java
! ))
{
do_linear_search = 1;
! }
! if (STRCMP (SYMBOL_NAME (*center), name) >= 0)
{
top = center;
}
*************** lookup_block_symbol (register const stru
*** 1226,1244 ****
}
inc = (inc >> 1) + bot;
sym = BLOCK_SYM (block, inc);
! if (!do_linear_search && (SYMBOL_LANGUAGE (sym) == language_java))
{
do_linear_search = 1;
}
! if (SYMBOL_SOURCE_NAME (sym)[0] < name[0])
{
bot = inc;
}
! else if (SYMBOL_SOURCE_NAME (sym)[0] > name[0])
{
top = inc;
}
! else if (STRCMP (SYMBOL_SOURCE_NAME (sym), name) < 0)
{
bot = inc;
}
--- 1217,1235 ----
}
inc = (inc >> 1) + bot;
sym = BLOCK_SYM (block, inc);
! if (!do_linear_search && ((SYMBOL_LANGUAGE (sym) == language_java) || SYMBOL_LANGUAGE (sym) == language_cplus))
{
do_linear_search = 1;
}
! if (SYMBOL_NAME (sym)[0] < name[0])
{
bot = inc;
}
! else if (SYMBOL_NAME (sym)[0] > name[0])
{
top = inc;
}
! else if (STRCMP (SYMBOL_NAME (sym), name) < 0)
{
bot = inc;
}