This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] thinko in find_symbol_in_baseclass
- From: Doug Evans <dje at google dot com>
- To: gdb-patches at sourceware dot org, keiths at redhat dot com
- Date: Mon, 27 May 2013 23:54:19 -0700
- Subject: [RFA] thinko in find_symbol_in_baseclass
Hi.
cp-namespace.cc:find_symbol_in_baseclass has this.
There's a missing check for sym != NULL.
len = strlen (base_name) + 2 + strlen (name) + 1;
concatenated_name = xrealloc (concatenated_name, len);
xsnprintf (concatenated_name, len, "%s::%s", base_name, name);
sym = lookup_symbol_static (concatenated_name, block, VAR_DOMAIN);
>>> Missing sym != NULL check
/* If there is currently no BLOCK, e.g., the inferior hasn't yet
been started, then try searching all STATIC_BLOCK symbols in
all objfiles. */
if (block == NULL)
{
sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
if (sym != NULL)
break;
}
However, digging a bit deeper there's no need to search for
static blocks here, it's already been done.
I could be missing something of course.
There are no regressions in the testsuite at least. :-)
[Searching STATIC_BLOCK with psyms does a linear search,
we want to avoid that where possible and at least not duplicate it. :-)]
btw, it's not clear to me what the tail of this comment means:
We do not try to
guess any imported namespace as even the fully specified
namespace search is already not C++ compliant and more
assumptions could make it too magic.
IWBN to clarify this.
Ok to check in?
2013-05-27 Doug Evans <dje@google.com>
* cp-namespace.c (find_symbol_in_baseclass): Remove unnecessary
duplicate check for symbols in STATIC_BLOCK.
(cp_lookup_nested_symbol): Improve comment.
Index: cp-namespace.c
===================================================================
RCS file: /cvs/src/src/gdb/cp-namespace.c,v
retrieving revision 1.66
diff -u -p -r1.66 cp-namespace.c
--- cp-namespace.c 14 Mar 2013 11:13:34 -0000 1.66
+++ cp-namespace.c 28 May 2013 06:31:20 -0000
@@ -727,21 +727,6 @@ find_symbol_in_baseclass (struct type *p
if (sym != NULL)
break;
- len = strlen (base_name) + 2 + strlen (name) + 1;
- concatenated_name = xrealloc (concatenated_name, len);
- xsnprintf (concatenated_name, len, "%s::%s", base_name, name);
- sym = lookup_symbol_static (concatenated_name, block, VAR_DOMAIN);
-
- /* If there is currently no BLOCK, e.g., the inferior hasn't yet
- been started, then try searching all STATIC_BLOCK symbols in
- all objfiles. */
- if (block == NULL)
- {
- sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
- if (sym != NULL)
- break;
- }
-
/* If this class has base classes, search them next. */
if (TYPE_N_BASECLASSES (TYPE_BASECLASS (parent_type, i)) > 0)
{
@@ -794,8 +779,8 @@ cp_lookup_nested_symbol (struct type *pa
if (sym != NULL)
return sym;
- /* Now search all static file-level symbols. Not strictly
- correct, but more useful than an error. We do not try to
+ /* Now search all static file-level symbols. We have to do this
+ for things like typedefs in the class. We do not try to
guess any imported namespace as even the fully specified
namespace search is already not C++ compliant and more
assumptions could make it too magic. */