[V4,5/9] New probe type: DTrace USDT probes.
Commit Message
> >> > Well, the TRY..CATCH in your prototype would catch any error that may be
> >> > thrown in parse_expression, and the `set_language' must take care of
> >> > changing the language, so I would say that is enough...
> >>
> >> OK - I will send an updated patch that makes things a little cleaner.
> >> I didn't know whether it was OK to default to type long makes much
> >> sense when the probe says the parameter should be using type "mutex_t".
>
> I remember we had the same problem (i.e., not parsing using language_c)
> on SystemTap SDT probes as well. Coincidentally or not, you triggered
> the problem twice!
The curse of using a cool language on exotic platforms :-).
> > The problem occurs while trying to parse a probe's arguument,
>
> "argument"
> > + if (current_language->la_language != language_c)
> > + {
> > + old_chain = make_cleanup_restore_current_language ();
> > + set_language (language_c);
> > + }
>
> Here I think you meant to use "lang" instead of "language_c", right?
Duh...
Thanks for reviewing the entire patch! Attached is what I just pushed.
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.
Tested on sparc-solaris and also on x86_64-linux, just for kicks.
Comments
Hi all,
I think this patch (commit 429e1e811b400f07b5a514ea6b8a70b28e2d7ee9) causes
gdb's compilation to fail with GCC 4.4.7 (RHEL 6 system compiler) as follows;
it does work with GCC 5.
cc1: warnings being treated as errors
../../gdb/dtrace-probe.c: In function ‘dtrace_process_dof_probe’:
../../gdb/dtrace-probe.c:416: error: ‘expr’ may be used uninitialized in this function
make[2]: *** [dtrace-probe.o] Error 1
I think that looks spurious as the code looks fine (i.e. GCC is overzaelous), still,
a "= NULL" should harm.
Tobias
414 {
415 struct dtrace_probe_arg arg;
416 struct expression *expr;
...
431 TRY
432 {
433 expr = parse_expression_with_language (arg.type_str, language_c);
434 }
435 CATCH (ex, RETURN_MASK_ERROR)
436 {
437 expr = NULL;
438 }
439 END_CATCH
440
441 if (expr != NULL && expr->elts[0].opcode == OP_TYPE)
442 arg.type = expr->elts[1].type;
From 429e1e811b400f07b5a514ea6b8a70b28e2d7ee9 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Thu, 26 Mar 2015 19:14:03 +0100
Subject: [PATCH] dtrace-probe: Handle error while parsing probe argument.
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 | 8 ++++++++
gdb/dtrace-probe.c | 14 ++++++++++++--
gdb/expression.h | 3 +++
gdb/parse.c | 22 ++++++++++++++++++++++
4 files changed, 45 insertions(+), 2 deletions(-)
@@ -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".
@@ -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);
@@ -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 *);
@@ -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,
--
1.9.1