Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC/RFA] Add handling for unqualified Ada operators in linespecs
@ 2011-12-13 21:24 Joel Brobecker
  2011-12-16 19:32 ` Tom Tromey
  0 siblings, 1 reply; 9+ messages in thread
From: Joel Brobecker @ 2011-12-13 21:24 UTC (permalink / raw)
  To: gdb-patches; +Cc: Joel Brobecker

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-21  7:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-13 21:24 [RFC/RFA] Add handling for unqualified Ada operators in linespecs Joel Brobecker
2011-12-16 19:32 ` Tom Tromey
2011-12-16 19:33   ` Doug Evans
2011-12-16 20:09   ` Keith Seitz
2011-12-16 20:35     ` Tom Tromey
2011-12-17 14:55   ` Joel Brobecker
2011-12-20 15:30     ` Tom Tromey
2011-12-21  6:52       ` Joel Brobecker
2011-12-21  7:41   ` Joel Brobecker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox