summaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@gnat.com>2011-12-27 04:17:55 +0000
committerJoel Brobecker <brobecker@gnat.com>2011-12-27 04:17:55 +0000
commitc04316705c262c7a857ae87a5607d4b71ccc34e9 (patch)
tree9c6424c57273621c0609c3d50439c36c1938cca7 /gdb
parent41843fe8ff3cdc16b8c1448099f02cc19f362658 (diff)
downloadbinutils-gdb-c04316705c262c7a857ae87a5607d4b71ccc34e9.tar.gz
New function ada-lang.c:should_use_wild_match...
... to avoid code duplication. gdb/ChangeLog: * ada-lang.c (should_use_wild_match): New function. (ada_lookup_simple_minsym): Use should_use_wild_match. Minor simplification. Add comment. (ada_lookup_symbol_list): Use should_use_wild_match. Minor simplification.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/ada-lang.c32
2 files changed, 30 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index db084272284..87031a62c2a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
2011-12-27 Joel Brobecker <brobecker@adacore.com>
+ * ada-lang.c (should_use_wild_match): New function.
+ (ada_lookup_simple_minsym): Use should_use_wild_match.
+ Minor simplification. Add comment.
+ (ada_lookup_symbol_list): Use should_use_wild_match.
+ Minor simplification.
+
+2011-12-27 Joel Brobecker <brobecker@adacore.com>
+
* py-finishbreakpoint.c (bpfinishpy_init): Replace call to
sprintf by call to xsnprintf.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 41e81ab8747..c4bf6e9e846 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4161,6 +4161,18 @@ cache_symbol (const char *name, domain_enum namespace, struct symbol *sym,
/* Symbol Lookup */
+/* Return nonzero if wild matching should be used when searching for
+ all symbols matching LOOKUP_NAME.
+
+ LOOKUP_NAME is expected to be a symbol name after transformation
+ for Ada lookups (see ada_name_for_lookup). */
+
+static int
+should_use_wild_match (const char *lookup_name)
+{
+ return (strstr (lookup_name, "__") == NULL);
+}
+
/* Return the result of a standard (literal, C-like) lookup of NAME in
given DOMAIN, visible from lexical block BLOCK. */
@@ -4326,15 +4338,17 @@ ada_lookup_simple_minsym (const char *name)
{
struct objfile *objfile;
struct minimal_symbol *msymbol;
- int wild_match;
+ const int wild_match = should_use_wild_match (name);
+ /* Special case: If the user specifies a symbol name inside package
+ Standard, do a non-wild matching of the symbol name without
+ the "standard__" prefix. This was primarily introduced in order
+ to allow the user to specifically access the standard exceptions
+ using, for instance, Standard.Constraint_Error when Constraint_Error
+ is ambiguous (due to the user defining its own Constraint_Error
+ entity inside its program). */
if (strncmp (name, "standard__", sizeof ("standard__") - 1) == 0)
- {
- name += sizeof ("standard__") - 1;
- wild_match = 0;
- }
- else
- wild_match = (strstr (name, "__") == NULL);
+ name += sizeof ("standard__") - 1;
ALL_MSYMBOLS (objfile, msymbol)
{
@@ -4978,7 +4992,7 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
struct symbol *sym;
struct block *block;
const char *name;
- int wild_match;
+ const int wild_match = should_use_wild_match (name0);
int cacheIfUnique;
int ndefns;
@@ -4989,7 +5003,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
/* Search specified block and its superiors. */
- wild_match = (strstr (name0, "__") == NULL);
name = name0;
block = (struct block *) block0; /* FIXME: No cast ought to be
needed, but adding const will
@@ -5004,7 +5017,6 @@ ada_lookup_symbol_list (const char *name0, const struct block *block0,
entity inside its program). */
if (strncmp (name0, "standard__", sizeof ("standard__") - 1) == 0)
{
- wild_match = 0;
block = NULL;
name = name0 + sizeof ("standard__") - 1;
}