From: Paul Hilfinger <hilfingr@gnat.com>
To: drow@false.org, jimb@redhat.com
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] Introduce notion of "search name"
Date: Mon, 03 May 2004 08:49:00 -0000 [thread overview]
Message-ID: <20040503084937.439F4F2C0A@nile.gnat.com> (raw)
In-Reply-To: <20040430134955.GA15786@nevyn.them.org> (message from Daniel Jacobowitz on Fri, 30 Apr 2004 09:49:55 -0400)
Dan & Jim,
> This is not what I was talking about - I was suggesting
> SYMBOL_DEMANGLED_NAME (symbol, objfile). That's more mechanical work
> but less confusing.
Ah. Well, a quick scan of the sources indicates that there are a few
places that ask for SYMBOL_PRINT_NAME in cases where it is not
apparent where to find an objfile. On the other hand, there are many
other cases where there IS an objfile immediately to hand, so I
suspect your design can be made to work. It won't, of course, be a
purely mechanical replacement.
> I don't care. Go ahead without doing this if Jim's OK with the patch
> otherwise. I'll come back and fix it in a year or two if I ever run
> out of memory leaks.
At the moment, I'd really like to concentrate on getting Ada support
turned on, and any leakage problems arising from these changes will affect
only Ada users (who haven't complained about them in the last 7 years). If
you can accept the patch largely as it is for now, I will undertake
to return to the objfile-finding problem after clearing my more immediate
hurdles.
As an update, here is the most recent version of my "search-name" patch.
Thanks for your attention.
Paul Hilfinger
ACT, Inc.
2004-05-03 Paul N. Hilfinger <hilfinger@gnat.com>
* symtab.h (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 (lookup_partial_symbol): Assume symbols ordered by
search name, using SYMBOL_SEARCH_NAME and SYMBOL_MATCHES_SEARCH_NAME.
(symbol_search_name): New function.
(symbol_demangled_search_name): New function.
* 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.61/gdb/minsyms.c
--- current-public.61/gdb/minsyms.c Wed, 31 Mar 2004 23:53:02 -0800 hilfingr (GdbPub/j/4_minsyms.c 1.1.1.3.1.1.1.1.1.1.1.1.1.1.3.2.2.1 644)
+++ current-public.61(w)/gdb/minsyms.c Sat, 01 May 2004 15:52:19 -0700 hilfingr (GdbPub/j/4_minsyms.c 1.1.1.3.1.1.1.1.1.1.1.1.1.1.3.2.2.1 644)
@@ -791,7 +791,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.61/gdb/symfile.c
--- current-public.61/gdb/symfile.c Sat, 01 May 2004 02:27:55 -0700 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.2.1.2.1.2.1 644)
+++ current-public.61(w)/gdb/symfile.c Mon, 03 May 2004 01:05:30 -0700 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.2.1.2.1.2.1 644)
@@ -207,8 +207,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.61/gdb/symtab.c
--- current-public.61/gdb/symtab.c Sat, 10 Apr 2004 00:36:50 -0700 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.2.1 644)
+++ current-public.61(w)/gdb/symtab.c Mon, 03 May 2004 01:41:17 -0700 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.2.1 644)
@@ -659,6 +659,18 @@ symbol_demangled_name (struct general_sy
return NULL;
}
+/* Return the search name of a symbol---i.e., the natural or linkage name
+ of the symbol, depending on how it will be searched for. */
+char *symbol_search_name (const struct general_symbol_info *gsymbol) {
+ return symbol_natural_name (gsymbol);
+}
+
+/* For languages that do not demangle or that do not do searches by
+ demangled name, return NULL. Otherwise, return the demangled name. */
+char *symbol_demangled_search_name (struct general_symbol_info *gsymbol) {
+ return symbol_demangled_name (gsymbol);
+}
+
/* Initialize the structure fields to zero values. */
void
init_sal (struct symtab_and_line *sal)
@@ -1467,7 +1479,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 +1494,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 +1515,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.61/gdb/symtab.h
--- current-public.61/gdb/symtab.h Sat, 10 Apr 2004 00:36:50 -0700 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.2.1.2.1 644)
+++ current-public.61(w)/gdb/symtab.h Mon, 03 May 2004 01:42:37 -0700 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.2.1.2.1 644)
@@ -258,6 +258,25 @@ 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 C++, Chill, and Java, we search for the demangled form of a name,
+ and so sort symbols accordingly. In Ada, however, we search by mangled
+ name. */
+#define SYMBOL_SEARCH_NAME(symbol) \
+ (symbol_search_name (&(symbol)->ginfo))
+extern char *symbol_search_name (const struct general_symbol_info *);
+
+/* 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_search_name (&(symbol)->ginfo))
+extern char *symbol_demangled_search_name (struct general_symbol_info *);
+
/* Classification types for a minimal symbol. These should be taken as
"advisory only", since if gdb can't easily figure out a
classification it simply selects mst_unknown. It may also have to
Index: current-public.61/gdb/dictionary.c
--- current-public.61/gdb/dictionary.c Tue, 17 Jun 2003 02:41:56 -0700 hilfingr (GdbPub/L/b/35_dictionary 1.1 644)
+++ current-public.61(w)/gdb/dictionary.c Sat, 01 May 2004 15:52:19 -0700 hilfingr (GdbPub/L/b/35_dictionary 1.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;
next prev parent reply other threads:[~2004-05-03 8:49 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-03 19:15 Paul Hilfinger
2004-03-19 0:09 ` Daniel Jacobowitz
2004-03-05 3:59 ` Daniel Jacobowitz
2004-03-05 10:39 ` Paul Hilfinger
2004-03-19 0:09 ` Paul Hilfinger
2004-03-31 22:12 ` Daniel Jacobowitz
2004-04-01 14:53 ` Jim Blandy
2004-04-01 15:00 ` Daniel Jacobowitz
2004-04-01 15:21 ` Jim Blandy
2004-04-02 9:30 ` Paul Hilfinger
2004-04-02 22:27 ` Jim Blandy
2004-04-03 12:04 ` Paul Hilfinger
2004-04-06 14:37 ` Jim Blandy
2004-04-02 9:33 ` Paul Hilfinger
2004-04-02 8:29 ` Paul Hilfinger
2004-04-09 22:40 ` Daniel Jacobowitz
2004-04-12 8:22 ` Paul Hilfinger
2004-04-16 4:11 ` Jim Blandy
2004-04-29 10:37 ` Paul Hilfinger
[not found] ` <20040429211458.GB27523@nevyn.them.org>
[not found] ` <vt2n04umj8b.fsf@zenia.home>
[not found] ` <20040430084538.ECDE1F2E1C@nile.gnat.com>
[not found] ` <20040430134955.GA15786@nevyn.them.org>
2004-05-03 8:49 ` Paul Hilfinger [this message]
2004-05-11 19:48 ` Daniel Jacobowitz
2004-05-12 11:00 ` Paul Hilfinger
2004-05-12 13:27 ` Daniel Jacobowitz
2004-05-12 14:14 ` Andrew Cagney
2004-05-12 14:23 ` Daniel Jacobowitz
2004-05-12 15:11 ` Andrew Cagney
2004-05-12 16:59 ` Joel Brobecker
2004-05-13 14:29 ` Andrew Cagney
2004-05-13 9:30 ` Paul Hilfinger
2004-05-13 13:49 ` Daniel Jacobowitz
2004-05-18 21:59 ` Jim Blandy
2004-05-19 9:55 ` Paul Hilfinger
2004-05-19 13:00 ` Daniel Jacobowitz
2004-05-19 15:21 ` Andrew Cagney
2004-05-20 10:18 ` Abstracting "name" Paul Hilfinger
2004-05-21 19:10 ` Andrew Cagney
2004-05-21 20:01 ` Jim Blandy
2004-03-19 0:09 ` [RFA] Introduce notion of "search name" Paul Hilfinger
2004-03-19 0:09 ` David Carlton
2004-03-03 19:26 ` David Carlton
2004-03-19 0:09 ` Paul Hilfinger
2004-03-04 8:45 ` Paul Hilfinger
2004-03-30 9:37 Paul Hilfinger
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=20040503084937.439F4F2C0A@nile.gnat.com \
--to=hilfingr@gnat.com \
--cc=drow@false.org \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@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