This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Introduce notion of "search name"


The following patch does nothing except to prepare the way for some later
Ada modifications by providing a few "hooks". I've discussed this 
modification earlier on this newsgroup.  At the moment, I've given
the definitions placeholder definitions that simply result in the
current semantics.  I propose to change them when Ada support is turned on.

The idea is to define "search name" as "the name that a language
module uses when searching for this symbol".  As discussed earlier,
the search name would be normally be the natural name, but in the case
of Ada, would just be the linkage name.

The modification to the signature of symbol_natural_name is to allow the
option of delayed (lazy) evaluation of the demangled name, which is
actually the point of introducing search names.

Paul Hilfinger

2004-03-03  Paul N. Hilfinger  <hilfinger@gnat.com>

	* symtab.h (symbol_natural_name): Remove const qualification 
	from argument.
	(SYMBOL_SEARCH_NAME): New definition.
	(SYMBOL_MATCHES_SEARCH_NAME): New definition.
	(SYMBOL_DEMANGLED_SEARCH_NAME): New definition.	

	* dictionary.c (iter_name_first_hashed): Match on SYMBOL_SEARCH_NAME.
	(iter_name_next_hashed): Ditto.
	(iter_name_next_linear): Ditto.
	(insert_symbol_hashed): Hash on SYMBOL_SEARCH_NAME.

	* symtab.c (symbol_natural_name): Remove const qualification from
	argument to allow lazy evaluation of demangled name.
	(lookup_partial_symbol): Assume symbols ordered by search name, using
	SYMBOL_SEARCH_NAME and SYMBOL_MATCHES_SEARCH_NAME.
	
	* symfile.c (compare_psymbols): Order by SYMBOL_SEARCH_NAME.
	
	* minsyms.c (build_minimal_symbol_hash_tables): Use 
	SYMBOL_DEMANGLED_SEARCH_NAME to test for adding to demangled
	hash table.
	

Index: current-public.49/gdb/minsyms.c
--- current-public.49/gdb/minsyms.c Mon, 09 Feb 2004 23:40:20 -0800 hilfingr (GdbPub/j/4_minsyms.c 1.1.1.3.1.1.1.1.1.1.1.1.1.1.3.2 644)
+++ submit.31(w)/gdb/minsyms.c Wed, 03 Mar 2004 00:34:32 -0800 hilfingr (GdbPub/j/4_minsyms.c 1.1.1.3.1.1.1.1.1.1.1.1.1.1.3.2.1.1 644)
@@ -794,7 +794,7 @@ build_minimal_symbol_hash_tables (struct
       add_minsym_to_hash_table (msym, objfile->msymbol_hash);
 
       msym->demangled_hash_next = 0;
-      if (SYMBOL_DEMANGLED_NAME (msym) != NULL)
+      if (SYMBOL_DEMANGLED_SEARCH_NAME (msym) != NULL)
 	add_minsym_to_demangled_hash_table (msym,
                                             objfile->msymbol_demangled_hash);
     }
Index: current-public.49/gdb/symfile.c
--- current-public.49/gdb/symfile.c Tue, 02 Mar 2004 23:57:04 -0800 hilfingr (GdbPub/k/48_symfile.c 1.1.1.7.1.1.1.2.1.1.1.1.1.1.1.1.1.1.3.1.1.2.1.1.1.1 644)
+++ submit.31(w)/gdb/symfile.c Wed, 03 Mar 2004 00:34:32 -0800 hilfingr (GdbPub/k/48_symfile.c 1.1.1.7.1.1.1.2.1.1.1.1.1.1.1.1.1.1.3.1.1.2.1.1.1.1.1.1 644)
@@ -208,8 +208,8 @@ compare_psymbols (const void *s1p, const
   struct partial_symbol *const *s1 = s1p;
   struct partial_symbol *const *s2 = s2p;
 
-  return strcmp_iw_ordered (SYMBOL_NATURAL_NAME (*s1),
-			    SYMBOL_NATURAL_NAME (*s2));
+  return strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*s1),
+			    SYMBOL_SEARCH_NAME (*s2));
 }
 
 void
Index: current-public.49/gdb/symtab.c
--- current-public.49/gdb/symtab.c Mon, 23 Feb 2004 00:44:25 -0800 hilfingr (GdbPub/k/50_symtab.c 1.1.1.4.1.1.1.1.1.1.1.1.1.1.2.1.2.1.1.1.1.1.1.1 644)
+++ submit.31(w)/gdb/symtab.c Wed, 03 Mar 2004 01:55:44 -0800 hilfingr (GdbPub/k/50_symtab.c 1.1.1.4.1.1.1.1.1.1.1.1.1.1.2.1.2.1.1.1.1.1.1.1.1.1 644)
@@ -630,7 +630,7 @@ symbol_init_demangled_name (struct gener
    demangling is necessary, this is the demangled name.  */
 
 char *
-symbol_natural_name (const struct general_symbol_info *gsymbol)
+symbol_natural_name (struct general_symbol_info *gsymbol)
 {
   if ((gsymbol->language == language_cplus
        || gsymbol->language == language_java
@@ -1467,7 +1467,7 @@ lookup_partial_symbol (struct partial_sy
 	    {
 	      do_linear_search = 1;
 	    }
-	  if (strcmp_iw_ordered (SYMBOL_NATURAL_NAME (*center), name) >= 0)
+	  if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), name) >= 0)
 	    {
 	      top = center;
 	    }
@@ -1482,7 +1482,7 @@ lookup_partial_symbol (struct partial_sy
       while (top <= real_top
 	     && (linkage_name != NULL
 		 ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
-		 : SYMBOL_MATCHES_NATURAL_NAME (*top,name)))
+		 : SYMBOL_MATCHES_SEARCH_NAME (*top,name)))
 	{
 	  if (SYMBOL_DOMAIN (*top) == domain)
 	    {
@@ -1503,7 +1503,7 @@ lookup_partial_symbol (struct partial_sy
 	    {
 	      if (linkage_name != NULL
 		  ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
-		  : SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
+		  : SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
 		{
 		  return (*psym);
 		}
Index: current-public.49/gdb/symtab.h
--- current-public.49/gdb/symtab.h Wed, 18 Feb 2004 01:34:45 -0800 hilfingr (GdbPub/l/2_symtab.h 1.1.1.5.1.1.1.1.1.1.1.1.1.1.3.1.1.1.1.1.1.1 644)
+++ submit.31(w)/gdb/symtab.h Wed, 03 Mar 2004 01:55:59 -0800 hilfingr (GdbPub/l/2_symtab.h 1.1.1.5.1.1.1.1.1.1.1.1.1.1.3.1.1.1.1.1.1.1.1.1 644)
@@ -213,7 +213,7 @@ extern void symbol_set_names (struct gen
 
 #define SYMBOL_NATURAL_NAME(symbol) \
   (symbol_natural_name (&(symbol)->ginfo))
-extern char *symbol_natural_name (const struct general_symbol_info *symbol);
+extern char *symbol_natural_name (struct general_symbol_info *symbol);
 
 /* Return SYMBOL's name from the point of view of the linker.  In
    languages like C++ where symbols may be mangled for ease of
@@ -257,6 +257,22 @@ extern char *symbol_demangled_name (stru
 
 #define SYMBOL_MATCHES_NATURAL_NAME(symbol, name)			\
   (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
+
+/* Macro that returns the name to be used when sorting and searching symbols. 
+   In most languages, we search for the demangled form of a name,
+   and so sort symbols accordingly. */
+#define SYMBOL_SEARCH_NAME(symbol)					 \
+  SYMBOL_NATURAL_NAME (symbol)
+
+/* Analogous to SYMBOL_MATCHES_NATURAL_NAME, but uses the search
+   name. */
+#define SYMBOL_MATCHES_SEARCH_NAME(symbol, name)			\
+  (strcmp_iw (SYMBOL_SEARCH_NAME (symbol), (name)) == 0)
+
+/* For languages that do not demangle or that do not do searches by 
+   demangled name, NULL.  Otherwise, the demangled name. */
+#define SYMBOL_DEMANGLED_SEARCH_NAME(symbol)				 \
+  SYMBOL_DEMANGLED_NAME (symbol)
 
 /* Classification types for a minimal symbol.  These should be taken as
    "advisory only", since if gdb can't easily figure out a
Index: current-public.49/gdb/dictionary.c
--- current-public.49/gdb/dictionary.c Tue, 17 Jun 2003 02:41:56 -0700 hilfingr (GdbPub/L/b/35_dictionary 1.1 644)
+++ submit.31(w)/gdb/dictionary.c Wed, 03 Mar 2004 00:34:33 -0800 hilfingr (GdbPub/L/b/35_dictionary 1.1.4.1 644)
@@ -636,7 +636,7 @@ iter_name_first_hashed (const struct dic
        sym = sym->hash_next)
     {
       /* Warning: the order of arguments to strcmp_iw matters!  */
-      if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0)
+      if (strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
 	{
 	  break;
 	}
@@ -656,7 +656,7 @@ iter_name_next_hashed (const char *name,
        next != NULL;
        next = next->hash_next)
     {
-      if (strcmp_iw (SYMBOL_NATURAL_NAME (next), name) == 0)
+      if (strcmp_iw (SYMBOL_SEARCH_NAME (next), name) == 0)
 	break;
     }
 
@@ -674,7 +674,7 @@ insert_symbol_hashed (struct dictionary 
   unsigned int hash_index;
   struct symbol **buckets = DICT_HASHED_BUCKETS (dict);
 
-  hash_index = (msymbol_hash_iw (SYMBOL_NATURAL_NAME (sym))
+  hash_index = (msymbol_hash_iw (SYMBOL_SEARCH_NAME (sym))
 		% DICT_HASHED_NBUCKETS (dict));
   sym->hash_next = buckets[hash_index];
   buckets[hash_index] = sym;
@@ -789,7 +789,7 @@ iter_name_next_linear (const char *name,
   for (i = DICT_ITERATOR_INDEX (iterator) + 1; i < nsyms; ++i)
     {
       sym = DICT_LINEAR_SYM (dict, i);
-      if (strcmp_iw (SYMBOL_NATURAL_NAME (sym), name) == 0)
+      if (strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0)
 	{
 	  retval = sym;
 	  break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]