From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match...
Date: Fri, 23 Dec 2011 10:39:00 -0000 [thread overview]
Message-ID: <1324636693-24034-2-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <20111221140128.GK23376@adacore.com>
... to avoid code duplication.
This is just an independent cleanup which I'll commit shortly.
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.
---
gdb/ada-lang.c | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8f4292f..09ab38d 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,
\f
/* 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)
{
@@ -4979,7 +4993,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;
@@ -4990,7 +5004,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
@@ -5005,7 +5018,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;
}
--
1.7.1
next prev parent reply other threads:[~2011-12-23 10:38 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 14:36 [RFC] allow unqualified function names in linespecs Joel Brobecker
2011-12-20 15:24 ` Tom Tromey
2011-12-21 14:08 ` Joel Brobecker
2011-12-23 10:39 ` [RFA 2/3] Ada: " Joel Brobecker
2012-01-12 3:13 ` Joel Brobecker
2012-01-19 15:40 ` Joel Brobecker
2012-01-24 19:41 ` Tom Tromey
2012-01-26 4:23 ` Joel Brobecker
2012-01-26 10:22 ` Crash regression gdb.cp/no-dmgl-verbose.exp: " Jan Kratochvil
2012-01-26 10:55 ` Jan Kratochvil
2012-01-27 5:15 ` Jan Kratochvil
2012-01-27 5:25 ` Joel Brobecker
2012-01-27 17:09 ` [patch] Fix the 2012-01-26 regression by la_get_symbol_name_match_p [Re: Crash regression gdb.cp/no-dmgl-verbose.exp] Jan Kratochvil
2012-01-27 19:27 ` Joel Brobecker
2012-01-27 20:33 ` [commit] " Jan Kratochvil
2011-12-23 10:39 ` unqualified function names in linespecs in Ada... (try #2) Joel Brobecker
2011-12-23 10:39 ` Joel Brobecker [this message]
2011-12-27 4:27 ` Checked in: [commit/Ada 1/3] New function ada-lang.c:should_use_wild_match Joel Brobecker
2011-12-23 11:01 ` [RFA 3/3] Remove language param from name_matcher in struct quick_symbol_functions Joel Brobecker
2012-01-12 4:30 ` Joel Brobecker
2012-01-19 15:47 ` Joel Brobecker
2012-01-24 19:45 ` Tom Tromey
2012-01-26 4:57 ` Joel Brobecker
2012-01-24 19:17 ` [RFC] allow unqualified function names in linespecs Tom Tromey
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=1324636693-24034-2-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).