OSDN Git Service

do not call decode_compound with Ada expressions.
authorbrobecke <brobecke>
Wed, 4 Jan 2012 14:24:55 +0000 (14:24 +0000)
committerbrobecke <brobecke>
Wed, 4 Jan 2012 14:24:55 +0000 (14:24 +0000)
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 patch short-circuits this part of the code when the current
language is Ada.

gdb/ChangeLog:

        * linespec.c (decode_line_internal): Check for C++ or Java
        compound constructs only if the current language is C, C++
        or Java.

gdb/ChangeLog
gdb/linespec.c

index ac8f6d4..dfd010a 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-04  Joel Brobecker  <brobecker@adacore.com>
+
+       * linespec.c (decode_line_internal): Check for C++ or Java
+       compound constructs only if the current language is C, C++
+       or Java.
+
 2012-01-04  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Revert:
index 6276a3a..55cfec3 100644 (file)
@@ -951,33 +951,44 @@ decode_line_internal (struct linespec_state *self, char **argptr)
        
       if (p[0] == '.' || p[1] == ':')
        {
-         struct symtabs_and_lines values;
-         volatile struct gdb_exception ex;
-         char *saved_argptr = *argptr;
+        /* We only perform this check for the languages where it might
+           make 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_c
+             || current_language->la_language == language_cplus
+             || current_language->la_language == language_java)
+           {
+             struct symtabs_and_lines values;
+             volatile struct gdb_exception ex;
+             char *saved_argptr = *argptr;
 
-         if (is_quote_enclosed)
-           ++saved_arg;
+             if (is_quote_enclosed)
+               ++saved_arg;
 
-         /* Initialize it just to avoid a GCC false warning.  */
-         memset (&values, 0, sizeof (values));
+             /* Initialize it just to avoid a GCC false warning.  */
+             memset (&values, 0, sizeof (values));
 
-         TRY_CATCH (ex, RETURN_MASK_ERROR)
-           {
-             values = decode_compound (self, argptr, saved_arg, p);
-           }
-         if ((is_quoted || is_squote_enclosed) && **argptr == '\'')
-           *argptr = *argptr + 1;
+             TRY_CATCH (ex, RETURN_MASK_ERROR)
+               {
+                 values = decode_compound (self, argptr, saved_arg, p);
+               }
+             if ((is_quoted || is_squote_enclosed) && **argptr == '\'')
+               *argptr = *argptr + 1;
 
-         if (ex.reason >= 0)
-           {
-             do_cleanups (cleanup);
-             return values;
-           }
+             if (ex.reason >= 0)
+               {
+                 do_cleanups (cleanup);
+                 return values;
+               }
 
-         if (ex.error != NOT_FOUND_ERROR)
-           throw_exception (ex);
+             if (ex.error != NOT_FOUND_ERROR)
+               throw_exception (ex);
 
-         *argptr = saved_argptr;
+             *argptr = saved_argptr;
+           }
        }
       else
        {