* [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h
@ 2003-02-27 23:01 David Carlton
2003-03-02 23:48 ` Elena Zannoni
0 siblings, 1 reply; 4+ messages in thread
From: David Carlton @ 2003-02-27 23:01 UTC (permalink / raw)
To: gdb-patches; +Cc: Elena Zannoni, Jim Blandy
This gets rid of the uses of DEPRECATED_SYMBOL_NAME in symtab.h. It
is used in two macros: SYMBOL_MATCHES_NAME and SYMBOL_MATCHES_REGEXP.
For SYMBOL_MATCHES_REGEXP, the situation is relatively
straightforward: have the regexp always try to match against
SYMBOL_NATURAL_NAME. This macro is only used in search_symbols; this
redefinition of SYMBOL_MATCHES_REGEXP is, in my opinion, correct
behavior for search_symbols.
SYMBOL_MATCHES_NAME is a bit more complicated. Right now
SYMBOL_MATCHES_NAME either compares against DEPRECATED_SYMBOL_NAME
using strcmp or against SYMBOL_DEMANGLED_NAME (if it's non-NULL) using
strcmp_iw. As Michael Chastain noted in PR gdb/33, for the uses of
SYMBOL_MATCHES_NAME in symtab.c, you really always want to use
strcmp_iw. Unfortunately (as the test suite kindly let me know;
always nice when a test I wrote later catches me in a bit of
foolishness), SYMBOL_MATCHES_NAME is used in minsyms.c in situations
where sometimes you want to match against the linkage name and
sometimes you want to match agaist the natural name. (It's that
stupid loop over two hash tables.)
So what I've done is renamed the current SYMBOL_MATCHES_NAME to
DEPRECATED_SYMBOL_MATCHES_NAME and used that in minsyms.c. (At some
point, I'll fix lookup_minimal_symbol to do the right thing, but not
today.) And I added a new macro SYMBOL_MATCHES_NATURAL_NAME that
compares 'name' to SYMBOL_NATURAL_NAME(symbol) using strcmp_iw. I
used that in symtab.c; this fixes PR gdb/33.
One note if you test this patch against the current test suite: there
are a pair of tests in gdb.c++/templates.exp, both named 'print
Foo:<something>::foo', that together test for PR gdb/33. Right now,
one of them KFAILs and the other either PASSes or FAILs, depending on
what compiler you use. After this patch, they'll both do the same
thing, namely both PASS or both FAIL. That's a good thing: it means
that the KFAIL corresponding to gdb/33 has gone away. (In fact, the
FAIL is a testsuite bug; I have a separate patch for that that will go
in tomorrow.)
Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2; OK to commit?
David Carlton
carlton@math.stanford.edu
2003-02-27 David Carlton <carlton@math.stanford.edu>
* symtab.h (DEPRECATED_SYMBOL_MATCHES_NAME): Rename from
SYMBOL_MATCHES_NAME, add comment.
(SYMBOL_MATCHES_NATURAL_NAME): New.
(SYMBOL_MATCHES_REGEXP): Use SYMBOL_NATURAL_NAME.
* minsyms.c (lookup_minimal_symbol_solib_trampoline): Replace
SYMBOL_MATCHES_NAME with DEPRECATED_SYMBOL_MATCHES_NAME.
(lookup_minimal_symbol, lookup_minimal_symbol_text): Ditto.
* symtab.c (lookup_partial_symbol): Use
SYMBOL_MATCHES_NATURAL_NAME, not SYMBOL_MATCHES_NAME. Delete
unhelpful comment.
(lookup_block_symbol): Use SYMBOL_MATCHES_NATURAL_NAME, not
SYMBOL_MATCHES_NAME.
Fix for PR c++/33.
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.63
diff -u -p -r1.63 symtab.h
--- symtab.h 25 Feb 2003 21:36:20 -0000 1.63
+++ symtab.h 27 Feb 2003 22:18:00 -0000
@@ -217,20 +217,30 @@ extern char *symbol_demangled_name (stru
"foo :: bar (int, long)".
Evaluates to zero if the match fails, or nonzero if it succeeds. */
-#define SYMBOL_MATCHES_NAME(symbol, name) \
+/* FIXME: carlton/2003-02-27: This is an unholy mixture of linkage
+ names and natural names. If you want to test the linkage names
+ with strcmp, do that. If you want to test the natural names with
+ strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME. */
+
+#define DEPRECATED_SYMBOL_MATCHES_NAME(symbol, name) \
(STREQ (DEPRECATED_SYMBOL_NAME (symbol), (name)) \
|| (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
&& strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
-/* Macro that tests a symbol for an re-match against the last compiled regular
- expression. First test the unencoded name, then look for and test a C++
- encoded name if it exists.
- Evaluates to zero if the match fails, or nonzero if it succeeds. */
+/* Macro that tests a symbol for a match against a specified name
+ string. It tests against SYMBOL_NATURAL_NAME, and it ignores
+ whitespace and trailing parentheses. (See strcmp_iw for details
+ about its behavior.) */
+
+#define SYMBOL_MATCHES_NATURAL_NAME(symbol, name) \
+ (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
+
+/* Macro that tests SYMBOL_NATURAL_NAME(symbol) for an re-match
+ against the last compiled regular expression. Evaluates to zero if
+ the match fails, or nonzero if it succeeds. */
#define SYMBOL_MATCHES_REGEXP(symbol) \
- (re_exec (DEPRECATED_SYMBOL_NAME (symbol)) != 0 \
- || (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
- && re_exec (SYMBOL_DEMANGLED_NAME (symbol)) != 0))
+ (re_exec (SYMBOL_NATURAL_NAME (symbol)) != 0)
/* Define a simple structure used to hold some very basic information about
all defined global symbols (text, data, bss, abs, etc). The only required
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.96
diff -u -p -r1.96 symtab.c
--- symtab.c 27 Feb 2003 20:48:03 -0000 1.96
+++ symtab.c 27 Feb 2003 22:18:07 -0000
@@ -1423,10 +1423,7 @@ lookup_partial_symbol (struct partial_sy
if (!(top == bottom))
internal_error (__FILE__, __LINE__, "failed internal consistency check");
- /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
- we don't have to force a linear search on C++. Probably holds true
- for JAVA as well, no way to check.*/
- while (top <= real_top && SYMBOL_MATCHES_NAME (*top,name))
+ while (top <= real_top && SYMBOL_MATCHES_NATURAL_NAME (*top,name))
{
if (SYMBOL_NAMESPACE (*top) == namespace)
{
@@ -1445,7 +1442,7 @@ lookup_partial_symbol (struct partial_sy
{
if (namespace == SYMBOL_NAMESPACE (*psym))
{
- if (SYMBOL_MATCHES_NAME (*psym, name))
+ if (SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
{
return (*psym);
}
@@ -1623,7 +1620,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
return sym;
}
return NULL;
@@ -1693,7 +1690,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
{
return sym;
}
@@ -1728,7 +1725,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
{
/* If SYM has aliases, then use any alias that is active
at the current PC. If no alias is active at the current
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.26
diff -u -p -r1.26 minsyms.c
--- minsyms.c 25 Feb 2003 21:36:18 -0000 1.26
+++ minsyms.c 27 Feb 2003 22:18:12 -0000
@@ -188,7 +188,7 @@ lookup_minimal_symbol (register const ch
while (msymbol != NULL && found_symbol == NULL)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name))
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name))
{
switch (MSYMBOL_TYPE (msymbol))
{
@@ -288,7 +288,7 @@ lookup_minimal_symbol_text (register con
msymbol != NULL && found_symbol == NULL;
msymbol = msymbol->hash_next)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name) &&
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
(MSYMBOL_TYPE (msymbol) == mst_text ||
MSYMBOL_TYPE (msymbol) == mst_file_text))
{
@@ -364,7 +364,7 @@ lookup_minimal_symbol_solib_trampoline (
msymbol != NULL && found_symbol == NULL;
msymbol = msymbol->hash_next)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name) &&
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
return msymbol;
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h
2003-02-27 23:01 [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h David Carlton
@ 2003-03-02 23:48 ` Elena Zannoni
2003-03-03 18:04 ` David Carlton
0 siblings, 1 reply; 4+ messages in thread
From: Elena Zannoni @ 2003-03-02 23:48 UTC (permalink / raw)
To: David Carlton; +Cc: gdb-patches, Elena Zannoni, Jim Blandy
David Carlton writes:
> This gets rid of the uses of DEPRECATED_SYMBOL_NAME in symtab.h. It
> is used in two macros: SYMBOL_MATCHES_NAME and SYMBOL_MATCHES_REGEXP.
>
> For SYMBOL_MATCHES_REGEXP, the situation is relatively
> straightforward: have the regexp always try to match against
> SYMBOL_NATURAL_NAME. This macro is only used in search_symbols; this
> redefinition of SYMBOL_MATCHES_REGEXP is, in my opinion, correct
> behavior for search_symbols.
>
Yes, just a few things.
I think it would make more sense to get rid of the REGEXP macro
completely. There are only 4 occurrences, and you are really
simplifying it. This should go in as one commit.
As a separate commit you can check in the rest of this patch, to fix
gdb/33.
i.e. deal with one macro at the time.
elena
> SYMBOL_MATCHES_NAME is a bit more complicated. Right now
> SYMBOL_MATCHES_NAME either compares against DEPRECATED_SYMBOL_NAME
> using strcmp or against SYMBOL_DEMANGLED_NAME (if it's non-NULL) using
> strcmp_iw. As Michael Chastain noted in PR gdb/33, for the uses of
> SYMBOL_MATCHES_NAME in symtab.c, you really always want to use
> strcmp_iw. Unfortunately (as the test suite kindly let me know;
> always nice when a test I wrote later catches me in a bit of
> foolishness), SYMBOL_MATCHES_NAME is used in minsyms.c in situations
> where sometimes you want to match against the linkage name and
> sometimes you want to match agaist the natural name. (It's that
> stupid loop over two hash tables.)
>
> So what I've done is renamed the current SYMBOL_MATCHES_NAME to
> DEPRECATED_SYMBOL_MATCHES_NAME and used that in minsyms.c. (At some
> point, I'll fix lookup_minimal_symbol to do the right thing, but not
> today.) And I added a new macro SYMBOL_MATCHES_NATURAL_NAME that
> compares 'name' to SYMBOL_NATURAL_NAME(symbol) using strcmp_iw. I
> used that in symtab.c; this fixes PR gdb/33.
>
> One note if you test this patch against the current test suite: there
> are a pair of tests in gdb.c++/templates.exp, both named 'print
> Foo:<something>::foo', that together test for PR gdb/33. Right now,
> one of them KFAILs and the other either PASSes or FAILs, depending on
> what compiler you use. After this patch, they'll both do the same
> thing, namely both PASS or both FAIL. That's a good thing: it means
> that the KFAIL corresponding to gdb/33 has gone away. (In fact, the
> FAIL is a testsuite bug; I have a separate patch for that that will go
> in tomorrow.)
>
> Tested on i686-pc-linux-gnu/GCC3.1/DWARF-2; OK to commit?
>
> David Carlton
> carlton@math.stanford.edu
>
> 2003-02-27 David Carlton <carlton@math.stanford.edu>
>
> * symtab.h (DEPRECATED_SYMBOL_MATCHES_NAME): Rename from
> SYMBOL_MATCHES_NAME, add comment.
> (SYMBOL_MATCHES_NATURAL_NAME): New.
> (SYMBOL_MATCHES_REGEXP): Use SYMBOL_NATURAL_NAME.
> * minsyms.c (lookup_minimal_symbol_solib_trampoline): Replace
> SYMBOL_MATCHES_NAME with DEPRECATED_SYMBOL_MATCHES_NAME.
> (lookup_minimal_symbol, lookup_minimal_symbol_text): Ditto.
> * symtab.c (lookup_partial_symbol): Use
> SYMBOL_MATCHES_NATURAL_NAME, not SYMBOL_MATCHES_NAME. Delete
> unhelpful comment.
> (lookup_block_symbol): Use SYMBOL_MATCHES_NATURAL_NAME, not
> SYMBOL_MATCHES_NAME.
> Fix for PR c++/33.
>
> Index: symtab.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.h,v
> retrieving revision 1.63
> diff -u -p -r1.63 symtab.h
> --- symtab.h 25 Feb 2003 21:36:20 -0000 1.63
> +++ symtab.h 27 Feb 2003 22:18:00 -0000
> @@ -217,20 +217,30 @@ extern char *symbol_demangled_name (stru
> "foo :: bar (int, long)".
> Evaluates to zero if the match fails, or nonzero if it succeeds. */
>
> -#define SYMBOL_MATCHES_NAME(symbol, name) \
> +/* FIXME: carlton/2003-02-27: This is an unholy mixture of linkage
> + names and natural names. If you want to test the linkage names
> + with strcmp, do that. If you want to test the natural names with
> + strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME. */
> +
> +#define DEPRECATED_SYMBOL_MATCHES_NAME(symbol, name) \
> (STREQ (DEPRECATED_SYMBOL_NAME (symbol), (name)) \
> || (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
> && strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
>
> -/* Macro that tests a symbol for an re-match against the last compiled regular
> - expression. First test the unencoded name, then look for and test a C++
> - encoded name if it exists.
> - Evaluates to zero if the match fails, or nonzero if it succeeds. */
> +/* Macro that tests a symbol for a match against a specified name
> + string. It tests against SYMBOL_NATURAL_NAME, and it ignores
> + whitespace and trailing parentheses. (See strcmp_iw for details
> + about its behavior.) */
> +
> +#define SYMBOL_MATCHES_NATURAL_NAME(symbol, name) \
> + (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
> +
> +/* Macro that tests SYMBOL_NATURAL_NAME(symbol) for an re-match
> + against the last compiled regular expression. Evaluates to zero if
> + the match fails, or nonzero if it succeeds. */
>
> #define SYMBOL_MATCHES_REGEXP(symbol) \
> - (re_exec (DEPRECATED_SYMBOL_NAME (symbol)) != 0 \
> - || (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
> - && re_exec (SYMBOL_DEMANGLED_NAME (symbol)) != 0))
> + (re_exec (SYMBOL_NATURAL_NAME (symbol)) != 0)
>
> /* Define a simple structure used to hold some very basic information about
> all defined global symbols (text, data, bss, abs, etc). The only required
> Index: symtab.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/symtab.c,v
> retrieving revision 1.96
> diff -u -p -r1.96 symtab.c
> --- symtab.c 27 Feb 2003 20:48:03 -0000 1.96
> +++ symtab.c 27 Feb 2003 22:18:07 -0000
> @@ -1423,10 +1423,7 @@ lookup_partial_symbol (struct partial_sy
> if (!(top == bottom))
> internal_error (__FILE__, __LINE__, "failed internal consistency check");
>
> - /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
> - we don't have to force a linear search on C++. Probably holds true
> - for JAVA as well, no way to check.*/
> - while (top <= real_top && SYMBOL_MATCHES_NAME (*top,name))
> + while (top <= real_top && SYMBOL_MATCHES_NATURAL_NAME (*top,name))
> {
> if (SYMBOL_NAMESPACE (*top) == namespace)
> {
> @@ -1445,7 +1442,7 @@ lookup_partial_symbol (struct partial_sy
> {
> if (namespace == SYMBOL_NAMESPACE (*psym))
> {
> - if (SYMBOL_MATCHES_NAME (*psym, name))
> + if (SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
> {
> return (*psym);
> }
> @@ -1623,7 +1620,7 @@ lookup_block_symbol (register const stru
> if (SYMBOL_NAMESPACE (sym) == namespace
> && (mangled_name
> ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
> - : SYMBOL_MATCHES_NAME (sym, name)))
> + : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
> return sym;
> }
> return NULL;
> @@ -1693,7 +1690,7 @@ lookup_block_symbol (register const stru
> if (SYMBOL_NAMESPACE (sym) == namespace
> && (mangled_name
> ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
> - : SYMBOL_MATCHES_NAME (sym, name)))
> + : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
> {
> return sym;
> }
> @@ -1728,7 +1725,7 @@ lookup_block_symbol (register const stru
> if (SYMBOL_NAMESPACE (sym) == namespace
> && (mangled_name
> ? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
> - : SYMBOL_MATCHES_NAME (sym, name)))
> + : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
> {
> /* If SYM has aliases, then use any alias that is active
> at the current PC. If no alias is active at the current
> Index: minsyms.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/minsyms.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 minsyms.c
> --- minsyms.c 25 Feb 2003 21:36:18 -0000 1.26
> +++ minsyms.c 27 Feb 2003 22:18:12 -0000
> @@ -188,7 +188,7 @@ lookup_minimal_symbol (register const ch
>
> while (msymbol != NULL && found_symbol == NULL)
> {
> - if (SYMBOL_MATCHES_NAME (msymbol, name))
> + if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name))
> {
> switch (MSYMBOL_TYPE (msymbol))
> {
> @@ -288,7 +288,7 @@ lookup_minimal_symbol_text (register con
> msymbol != NULL && found_symbol == NULL;
> msymbol = msymbol->hash_next)
> {
> - if (SYMBOL_MATCHES_NAME (msymbol, name) &&
> + if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
> (MSYMBOL_TYPE (msymbol) == mst_text ||
> MSYMBOL_TYPE (msymbol) == mst_file_text))
> {
> @@ -364,7 +364,7 @@ lookup_minimal_symbol_solib_trampoline (
> msymbol != NULL && found_symbol == NULL;
> msymbol = msymbol->hash_next)
> {
> - if (SYMBOL_MATCHES_NAME (msymbol, name) &&
> + if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
> MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
> return msymbol;
> }
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h
2003-03-02 23:48 ` Elena Zannoni
@ 2003-03-03 18:04 ` David Carlton
2003-03-03 18:36 ` David Carlton
0 siblings, 1 reply; 4+ messages in thread
From: David Carlton @ 2003-03-03 18:04 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, Jim Blandy
On Sun, 2 Mar 2003 18:52:49 -0500, Elena Zannoni <ezannoni@redhat.com> said:
> I think it would make more sense to get rid of the REGEXP macro
> completely. There are only 4 occurrences, and you are really
> simplifying it. This should go in as one commit.
> As a separate commit you can check in the rest of this patch, to fix
> gdb/33.
> i.e. deal with one macro at the time.
Good idea. Here's the regexp patch, which I've just committed; I'll
prepare the other one in a few minutes.
David Carlton
carlton@math.stanford.edu
2003-03-03 David Carlton <carlton@math.stanford.edu>
* symtab.h (SYMBOL_MATCHES_REGEXP): Delete.
* symtab.c (search_symbols): Replace uses of SYMBOL_MATCHES_REGEXP
by regexp matching against SYMBOL_NATURAL_NAME.
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.63
diff -u -p -r1.63 symtab.h
--- symtab.h 25 Feb 2003 21:36:20 -0000 1.63
+++ symtab.h 3 Mar 2003 18:00:28 -0000
@@ -222,16 +222,6 @@ extern char *symbol_demangled_name (stru
|| (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
&& strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
-/* Macro that tests a symbol for an re-match against the last compiled regular
- expression. First test the unencoded name, then look for and test a C++
- encoded name if it exists.
- Evaluates to zero if the match fails, or nonzero if it succeeds. */
-
-#define SYMBOL_MATCHES_REGEXP(symbol) \
- (re_exec (DEPRECATED_SYMBOL_NAME (symbol)) != 0 \
- || (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
- && re_exec (SYMBOL_DEMANGLED_NAME (symbol)) != 0))
-
/* Define a simple structure used to hold some very basic information about
all defined global symbols (text, data, bss, abs, etc). The only required
information is the general_symbol_info.
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.96
diff -u -p -r1.96 symtab.c
--- symtab.c 27 Feb 2003 20:48:03 -0000 1.96
+++ symtab.c 3 Mar 2003 18:00:24 -0000
@@ -2931,7 +2931,8 @@ search_symbols (char *regexp, namespace_
/* If it would match (logic taken from loop below)
load the file and go on to the next one */
if (file_matches (ps->filename, files, nfiles)
- && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (*psym))
+ && ((regexp == NULL
+ || re_exec (SYMBOL_NATURAL_NAME (*psym)) != 0)
&& ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
&& SYMBOL_CLASS (*psym) != LOC_BLOCK)
|| (kind == FUNCTIONS_NAMESPACE && SYMBOL_CLASS (*psym) == LOC_BLOCK)
@@ -2968,7 +2969,8 @@ search_symbols (char *regexp, namespace_
MSYMBOL_TYPE (msymbol) == ourtype3 ||
MSYMBOL_TYPE (msymbol) == ourtype4)
{
- if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
+ if (regexp == NULL
+ || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
{
if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
{
@@ -3008,7 +3010,8 @@ search_symbols (char *regexp, namespace_
{
QUIT;
if (file_matches (s->filename, files, nfiles)
- && ((regexp == NULL || SYMBOL_MATCHES_REGEXP (sym))
+ && ((regexp == NULL
+ || re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
&& ((kind == VARIABLES_NAMESPACE && SYMBOL_CLASS (sym) != LOC_TYPEDEF
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
@@ -3062,7 +3065,8 @@ search_symbols (char *regexp, namespace_
MSYMBOL_TYPE (msymbol) == ourtype3 ||
MSYMBOL_TYPE (msymbol) == ourtype4)
{
- if (regexp == NULL || SYMBOL_MATCHES_REGEXP (msymbol))
+ if (regexp == NULL
+ || re_exec (SYMBOL_NATURAL_NAME (msymbol)) != 0)
{
/* Functions: Look up by address. */
if (kind != FUNCTIONS_NAMESPACE ||
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h
2003-03-03 18:04 ` David Carlton
@ 2003-03-03 18:36 ` David Carlton
0 siblings, 0 replies; 4+ messages in thread
From: David Carlton @ 2003-03-03 18:36 UTC (permalink / raw)
To: Elena Zannoni; +Cc: gdb-patches, Jim Blandy
On 03 Mar 2003 10:04:18 -0800, David Carlton <carlton@math.Stanford.EDU> said:
> On Sun, 2 Mar 2003 18:52:49 -0500, Elena Zannoni <ezannoni@redhat.com> said:
>> I think it would make more sense to get rid of the REGEXP macro
>> completely. There are only 4 occurrences, and you are really
>> simplifying it. This should go in as one commit.
>> As a separate commit you can check in the rest of this patch, to fix
>> gdb/33.
>> i.e. deal with one macro at the time.
> Good idea. Here's the regexp patch, which I've just committed; I'll
> prepare the other one in a few minutes.
And here's the other one, which I've also committed: no changes from
the previous version that I submitted (other than, of course, not
deleting SYMBOL_MATCHES_REGEXP).
David Carlton
carlton@math.stanford.edu
2003-03-03 David Carlton <carlton@math.stanford.edu>
* symtab.h (DEPRECATED_SYMBOL_MATCHES_NAME): Rename from
SYMBOL_MATCHES_NAME, add comment.
(SYMBOL_MATCHES_NATURAL_NAME): New.
* minsyms.c (lookup_minimal_symbol_solib_trampoline): Replace
SYMBOL_MATCHES_NAME with DEPRECATED_SYMBOL_MATCHES_NAME.
(lookup_minimal_symbol, lookup_minimal_symbol_text): Ditto.
* symtab.c (lookup_partial_symbol): Use
SYMBOL_MATCHES_NATURAL_NAME, not SYMBOL_MATCHES_NAME. Delete
unhelpful comment.
(lookup_block_symbol): Use SYMBOL_MATCHES_NATURAL_NAME, not
SYMBOL_MATCHES_NAME.
Fix for PR c++/33.
Index: symtab.h
===================================================================
RCS file: /cvs/src/src/gdb/symtab.h,v
retrieving revision 1.64
diff -u -p -r1.64 symtab.h
--- symtab.h 3 Mar 2003 18:01:33 -0000 1.64
+++ symtab.h 3 Mar 2003 18:32:22 -0000
@@ -217,10 +217,23 @@ extern char *symbol_demangled_name (stru
"foo :: bar (int, long)".
Evaluates to zero if the match fails, or nonzero if it succeeds. */
-#define SYMBOL_MATCHES_NAME(symbol, name) \
+/* FIXME: carlton/2003-02-27: This is an unholy mixture of linkage
+ names and natural names. If you want to test the linkage names
+ with strcmp, do that. If you want to test the natural names with
+ strcmp_iw, use SYMBOL_MATCHES_NATURAL_NAME. */
+
+#define DEPRECATED_SYMBOL_MATCHES_NAME(symbol, name) \
(STREQ (DEPRECATED_SYMBOL_NAME (symbol), (name)) \
|| (SYMBOL_DEMANGLED_NAME (symbol) != NULL \
&& strcmp_iw (SYMBOL_DEMANGLED_NAME (symbol), (name)) == 0))
+
+/* Macro that tests a symbol for a match against a specified name
+ string. It tests against SYMBOL_NATURAL_NAME, and it ignores
+ whitespace and trailing parentheses. (See strcmp_iw for details
+ about its behavior.) */
+
+#define SYMBOL_MATCHES_NATURAL_NAME(symbol, name) \
+ (strcmp_iw (SYMBOL_NATURAL_NAME (symbol), (name)) == 0)
/* Define a simple structure used to hold some very basic information about
all defined global symbols (text, data, bss, abs, etc). The only required
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.96
diff -u -p -r1.96 symtab.c
--- symtab.c 27 Feb 2003 20:48:03 -0000 1.96
+++ symtab.c 27 Feb 2003 22:18:07 -0000
@@ -1423,10 +1423,7 @@ lookup_partial_symbol (struct partial_sy
if (!(top == bottom))
internal_error (__FILE__, __LINE__, "failed internal consistency check");
- /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
- we don't have to force a linear search on C++. Probably holds true
- for JAVA as well, no way to check.*/
- while (top <= real_top && SYMBOL_MATCHES_NAME (*top,name))
+ while (top <= real_top && SYMBOL_MATCHES_NATURAL_NAME (*top,name))
{
if (SYMBOL_NAMESPACE (*top) == namespace)
{
@@ -1445,7 +1442,7 @@ lookup_partial_symbol (struct partial_sy
{
if (namespace == SYMBOL_NAMESPACE (*psym))
{
- if (SYMBOL_MATCHES_NAME (*psym, name))
+ if (SYMBOL_MATCHES_NATURAL_NAME (*psym, name))
{
return (*psym);
}
@@ -1623,7 +1620,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
return sym;
}
return NULL;
@@ -1693,7 +1690,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
{
return sym;
}
@@ -1728,7 +1725,7 @@ lookup_block_symbol (register const stru
if (SYMBOL_NAMESPACE (sym) == namespace
&& (mangled_name
? strcmp (DEPRECATED_SYMBOL_NAME (sym), mangled_name) == 0
- : SYMBOL_MATCHES_NAME (sym, name)))
+ : SYMBOL_MATCHES_NATURAL_NAME (sym, name)))
{
/* If SYM has aliases, then use any alias that is active
at the current PC. If no alias is active at the current
Index: minsyms.c
===================================================================
RCS file: /cvs/src/src/gdb/minsyms.c,v
retrieving revision 1.26
diff -u -p -r1.26 minsyms.c
--- minsyms.c 25 Feb 2003 21:36:18 -0000 1.26
+++ minsyms.c 27 Feb 2003 22:18:12 -0000
@@ -188,7 +188,7 @@ lookup_minimal_symbol (register const ch
while (msymbol != NULL && found_symbol == NULL)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name))
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name))
{
switch (MSYMBOL_TYPE (msymbol))
{
@@ -288,7 +288,7 @@ lookup_minimal_symbol_text (register con
msymbol != NULL && found_symbol == NULL;
msymbol = msymbol->hash_next)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name) &&
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
(MSYMBOL_TYPE (msymbol) == mst_text ||
MSYMBOL_TYPE (msymbol) == mst_file_text))
{
@@ -364,7 +364,7 @@ lookup_minimal_symbol_solib_trampoline (
msymbol != NULL && found_symbol == NULL;
msymbol = msymbol->hash_next)
{
- if (SYMBOL_MATCHES_NAME (msymbol, name) &&
+ if (DEPRECATED_SYMBOL_MATCHES_NAME (msymbol, name) &&
MSYMBOL_TYPE (msymbol) == mst_solib_trampoline)
return msymbol;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-03 18:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 23:01 [rfa] try to remove uses of DEPRECATED_SYMBOL_NAME in symtab.h David Carlton
2003-03-02 23:48 ` Elena Zannoni
2003-03-03 18:04 ` David Carlton
2003-03-03 18:36 ` David Carlton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox