aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorDoug Evans <xdje42@gmail.com>2014-12-17 00:30:29 -0800
committerDoug Evans <xdje42@gmail.com>2014-12-17 00:30:29 -0800
commit5e3c72e6b817a4d40a9ba551ed3c397098cdbfd4 (patch)
treef1315b6208b29aa718e97c49790e8225438fbeb2 /gdb
parentcc485e620197e6db42d942820d499b01794aeb00 (diff)
downloadgdb-5e3c72e6b817a4d40a9ba551ed3c397098cdbfd4.zip
gdb-5e3c72e6b817a4d40a9ba551ed3c397098cdbfd4.tar.gz
gdb-5e3c72e6b817a4d40a9ba551ed3c397098cdbfd4.tar.bz2
value_maybe_namespace_elt: Remove redundant call to lookup_static_symbol.
Anytime you can remove a symbol lookup that loops over all objfiles is A Good Thing. The call to lookup_static_symbol in valops.c:value_maybe_namespace_elt is redundant with this call in cp_lookup_nested_symbol: /* 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. */ size = strlen (parent_name) + 2 + strlen (nested_name) + 1; concatenated_name = alloca (size); xsnprintf (concatenated_name, size, "%s::%s", parent_name, nested_name); sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN); if (sym != NULL) return sym; Earlier in value_maybe_namespace_elt we do this: sym = cp_lookup_symbol_namespace (namespace_name, name, get_selected_block (0), VAR_DOMAIN); That sequence goes like: value_maybe_namespace_elt -> cp_lookup_symbol_namespace -> cp_lookup_symbol_in_namespace -> lookup_symbol_file -> cp_lookup_nested_symbol -> lookup_static_symbol The call was added in commit 41f62f3939b1c69e68ef5652feb44fef90eb85c9. https://sourceware.org/ml/gdb-patches/2010-06/msg00663.html With a part 2 here: https://sourceware.org/ml/gdb-patches/2010-06/msg00664.html At the time the call to lookup_static_symbol (spelled lookup_static_symbol_aux at the time) was needed. However, this patch, 8dea366bbed7986295681c101dcfbd35aeb6dfc4, https://sourceware.org/ml/gdb-patches/2012-11/msg00387.html augmented lookup_symbol_file to call cp_lookup_nested_symbol and introduced the redundancy. It's kinda buried, so it's totally not unexpected that this happened. gdb/ChangeLog: * valops.c (value_maybe_namespace_elt): Remove redundant call to lookup_static_symbol.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/valops.c9
2 files changed, 5 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5704d43..b672dc3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2014-12-17 Doug Evans <xdje42@gmail.com>
+ * valops.c (value_maybe_namespace_elt): Remove redundant call to
+ lookup_static_symbol.
+
+2014-12-17 Doug Evans <xdje42@gmail.com>
+
New parameter "debug symbol-lookup".
* NEWS: Mention it.
* cp-namespace.c (cp_lookup_symbol_imports_or_template): Add debug
diff --git a/gdb/valops.c b/gdb/valops.c
index 4d3059e..2f81a59f 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3570,15 +3570,6 @@ value_maybe_namespace_elt (const struct type *curtype,
get_selected_block (0), VAR_DOMAIN);
if (sym == NULL)
- {
- char *concatenated_name = alloca (strlen (namespace_name) + 2
- + strlen (name) + 1);
-
- sprintf (concatenated_name, "%s::%s", namespace_name, name);
- sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN);
- }
-
- if (sym == NULL)
return NULL;
else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
&& (SYMBOL_CLASS (sym) == LOC_TYPEDEF))