Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [RFC/RFA] Add handling for unqualified Ada operators in linespecs
Date: Tue, 13 Dec 2011 21:24:00 -0000	[thread overview]
Message-ID: <1323810763-5563-1-git-send-email-brobecker@adacore.com> (raw)

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


             reply	other threads:[~2011-12-13 21:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-13 21:24 Joel Brobecker [this message]
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

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=1323810763-5563-1-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