]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
dtrace-probe: Handle error while parsing probe argument.
authorJoel Brobecker <brobecker@adacore.com>
Thu, 26 Mar 2015 18:14:03 +0000 (19:14 +0100)
committerJoel Brobecker <brobecker@adacore.com>
Thu, 26 Mar 2015 20:56:51 +0000 (13:56 -0700)
The debugger on Solaris has been broken since the introduction of
DTrace probe support:

    (gdb) start
    Temporary breakpoint 1 at 0x80593bc: file simple_main.adb, line 4.
    Starting program: /[...]/simple_main
    [Thread debugging using libthread_db enabled]
    No definition of "mutex_t" in current context.

The problem occurs while trying to parse a probe's argument,
and the exception propagates all the way to the top. This patch
fixes the issue by containing the exception and falling back on
using the "long" builtin type if the argument's type could not
be determined.

Also, the parsing should be done using the C language parser.

gdb/ChangeLog:

        * dtrace-probe.c (dtrace_process_dof_probe): Contain any
        exception raised while parsing the probe arguments.
        Force parsing to be done using the C language parser.
        * expression.h (parse_expression_with_language): Declare.
        * parse.c (parse_expression_with_language): New function.

gdb/ChangeLog
gdb/dtrace-probe.c
gdb/expression.h
gdb/parse.c

index 70026d05da7c21bbda2c3168d2c91a6d4e3c252b..150b29a4f04e085a4b3f256e4d38acab4ed84eda 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-26  Joel Brobecker  <brobecker@adacore.com>
+
+       * dtrace-probe.c (dtrace_process_dof_probe): Contain any
+       exception raised while parsing the probe arguments.
+       Force parsing to be done using the C language parser.
+       * expression.h (parse_expression_with_language): Declare.
+       * parse.c (parse_expression_with_language): New function.
+
 2015-03-26  Jon Turney  <jon.turney@dronecode.org.uk>
 
        * MAINTAINERS (Write After Approval): Add "Jon Turney".
index 491d8538e62b8325f417f00495eac968bfd6d391..ff7ce7d868f6259e0776f7f0b3decc8cf8a9fada 100644 (file)
@@ -427,8 +427,18 @@ dtrace_process_dof_probe (struct objfile *objfile,
             this does not work then we set the type to `long
             int'.  */
           arg.type = builtin_type (gdbarch)->builtin_long;
-         expr = parse_expression (arg.type_str);
-         if (expr->elts[0].opcode == OP_TYPE)
+
+         TRY
+           {
+             expr = parse_expression_with_language (arg.type_str, language_c);
+           }
+         CATCH (ex, RETURN_MASK_ERROR)
+           {
+             expr = NULL;
+           }
+         END_CATCH
+
+         if (expr != NULL && expr->elts[0].opcode == OP_TYPE)
            arg.type = expr->elts[1].type;
 
          VEC_safe_push (dtrace_probe_arg_s, ret->args, &arg);
index 15ed354e37bb4037517e184bce5565bdb1c37b2a..6af83317f39fedd5be2490e4a8f150c7788afc1f 100644 (file)
@@ -97,6 +97,9 @@ struct expression
 
 extern struct expression *parse_expression (const char *);
 
+extern struct expression *parse_expression_with_language (const char *string,
+                                                         enum language lang);
+
 extern struct type *parse_expression_for_completion (const char *, char **,
                                                     enum type_code *);
 
index ec23dbb87ae1ada5a8d05efa19a9b5de17309782..6b59c4f7684a077409bfe73c99bb5b1601e0f37e 100644 (file)
@@ -1268,6 +1268,28 @@ parse_expression (const char *string)
   return exp;
 }
 
+/* Same as parse_expression, but using the given language (LANG)
+   to parse the expression.  */
+
+struct expression *
+parse_expression_with_language (const char *string, enum language lang)
+{
+  struct cleanup *old_chain = NULL;
+  struct expression *expr;
+
+  if (current_language->la_language != lang)
+    {
+      old_chain = make_cleanup_restore_current_language ();
+      set_language (lang);
+    }
+
+  expr = parse_expression (string);
+
+  if (old_chain != NULL)
+    do_cleanups (old_chain);
+  return expr;
+}
+
 /* Parse STRING as an expression.  If parsing ends in the middle of a
    field reference, return the type of the left-hand-side of the
    reference; furthermore, if the parsing ends in the field name,