This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC/RFA] do not call decode_compound with Ada expressions.


Trying to insert a breakpoint on `ops."<"', we get the following error:

    (gdb) b ops."<"
    malformed template specification in command

This is because locate_first_half skips the linespec until the dot,
and the decode_line_internal thinks that the dot might mean that
we have C++ or Java compound.  It then tries calling decode_compound
which errors out because it sees the opening angle bracket but not
the closing one (I am guessing).

This type of thing only really makes sense for certain languages,
but not Ada.  So this patch short-circuits this part of the code
when the current language is Ada.

Generally speaking, I think it would probably make sense to always
perform language-specific checks such as these only when the language
matches the check. With the current infrastructure, it would lead to
a lot of "if language is ... then [do...]", which would probably hard
to maintain, although maybe no less hard than it is now.  Perhaps
the work that KeithS is doing to parse the linespec will allow us
to have true language-specific evaluation of the linespec. I am
not sure yet.

gdb/ChangeLog:

        * linespec.c (decode_line_internal): Do not check for C++ or
        Java compound constructs if the current language is Ada.

The diff only shows the check that I added. The code inside the new
if block should be re-indented, which I haven't done as to not obfuscate
the diff (I could have done diff -B, maybe next time). I will fix
the patch if the patch is deemed OK.

Tested on x86_64-linux. Thoughts?

---
 gdb/linespec.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index 2201be3..0d9d759 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -956,6 +956,14 @@ decode_line_internal (struct linespec_state *self, char **argptr)
 	
       if (p[0] == '.' || p[1] == ':')
 	{
+	 /* We really should only be doing this for languages where
+	    it actually makes sense.  For instance, Ada does not use
+	    this type of syntax, and trying to apply this logic on
+	    an Ada linespec may trigger a spurious error (for instance,
+	    decode_compound does not like expressions such as `ops."<"',
+	    which is a valid function name in Ada).  */
+	  if (current_language->la_language != language_ada)
+	  {
 	  struct symtabs_and_lines values;
 	  volatile struct gdb_exception ex;
 	  char *saved_argptr = *argptr;
@@ -983,6 +991,7 @@ decode_line_internal (struct linespec_state *self, char **argptr)
 	    throw_exception (ex);
 
 	  *argptr = saved_argptr;
+	  }
 	}
       else
 	{
-- 
1.7.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]