This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC/RFA] Add handling for unqualified Ada operators in linespecs
- From: Joel Brobecker <brobecker at adacore dot com>
- To: gdb-patches at sourceware dot org
- Cc: Joel Brobecker <brobecker at adacore dot com>
- Date: Tue, 13 Dec 2011 16:12:43 -0500
- Subject: [RFC/RFA] Add handling for unqualified Ada operators in linespecs
Hello,
This patch enhances the linespec parser to recognize unqualified
operator names in linespecs. This allows the user to insert a breakpoint
on operator "+" as follow, for instance:
(gdb) break "+"
Previously, it was possible to insert such a breakpoint, but one
had to fully qualify the function name. For instance:
(gdb) break ops."+"
Not the most elegant solution, but relatively self contained. So
I thought I'd submit it, after all. It's still not completely
functional because, for it to work, it needs the symtabs to be
already read-in (or, in other words, the partial symbol search is
still not working). But that's actually another, much more general
problem, which is related to breakpoints using unqualified function
names in general. I will try to think about that on its own.
gdb/ChangeLog:
* linespec.c (locate_first_half): Add handling of Ada operators
when the current language is Ada.
Tested on x86_64-linux. It should also only affect Ada.
OK to apply?
---
gdb/linespec.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 0ac54f7..2201be3 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1334,6 +1334,24 @@ locate_first_half (char **argptr, int *is_quote_enclosed)
char *p, *p1;
int has_comma;
+ /* Check if the linespec starts with an Ada operator (such as "+",
+ or ">", for instance). */
+ p = *argptr;
+ if (p[0] == '"'
+ && current_language->la_language == language_ada)
+ {
+ const struct ada_opname_map *op;
+
+ for (op = ada_opname_table; op->encoded != NULL; op++)
+ if (strncmp (op->decoded, p, strlen (op->decoded)) == 0)
+ break;
+ if (op->encoded != NULL)
+ {
+ *is_quote_enclosed = 0;
+ return p + strlen (op->decoded);
+ }
+ }
+
/* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
and we must isolate the first half. Outer layers will call again later
for the second half.
--
1.7.1