From: Jim Blandy <jimb@codesourcery.com>
To: "Rob Quill" <rob.quill@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: New scope checking patch
Date: Thu, 10 Jan 2008 01:00:00 -0000 [thread overview]
Message-ID: <m363y2lcl1.fsf@codesourcery.com> (raw)
In-Reply-To: <baf6008d0711120829l3c0201aakf477dd4d6cfd440e@mail.gmail.com> (Rob Quill's message of "Mon, 12 Nov 2007 16:29:14 +0000")
"Rob Quill" <rob.quill at gmail.com> writes:
> The attached patch adds the ability to evaluate whether expressions
> are in scope without giving an error message. For example, if you were
> using a command file to control GDB then it it may not be ideal that
> the script stop executing due to a variable not being in scope at
> given position.
Hi, Rob. I'm sorry for dropping the review here.
Some mechanical points:
- Patches should have ChangeLog entries. For example, take a look at
this post:
http://sourceware.org/ml/gdb-patches/2008-01/msg00144.html
- Use 'cvs diff' to get the difference between your current sources
and the public file revisions they're based on; patches that affect
CVS metadata like "CVS/Entries" files can be treacherous if applied
unawares. :)
- GDB's code ought to follow the GNU Coding Standards; in particular,
lines shouldn't be longer than eighty characters. (c-exp.y in
particular has a lot of particularly horrible formatting, but we've
got to fight back; new patches should not make things worse.) Also,
indentation should follow GNU style, for consistency with the rest
of the code.
- The patch includes a number of hunks that are strictly whitespace
changes in code that's not otherwise involved in the change; they
require reviewers to check the 'before' and 'after' text by hand, to
see whether anything has actually changed. Try to keep extraneous
hunks out of patches.
As to the patch:
The functionality I originally suggested was to have an operator
$in_scope(X), where X is an identifier. What you've implemented is a
change that allows X to be an arbitrary expression, such that
$in_scope (X) is true if all the identifiers in X are bound. I gather
this was more useful for your original purpose, scripting GDB. That's
fine, but it does make the change a bit harder.
Having the $in_scope operator set a global flag which is cleared by
evaluate_expression isn't the ideal approach; global flags often have
effects beyond what was intended. For example:
- If I enter the expression '$in_scope (x) + y', the patch will
evaluate the entire expression using evaluate_for_scope, not just
the '$in_scope (x)' part. So $in_scope doesn't act like an operator
checking its operands; its presence affects the evaluation of the
whole expression.
- GDB sometimes parses an expression, and then evaluates it many times
over a long period of time (say, conditions for breakpoints).
Sometimes it parses an expression, and then doesn't evaluate it for
a while (say, 'display' expressions set when the program isn't
running). So setting check_scope when the expression is parsed, and
then checking and clearing it when the expression is evaluated,
won't work --- check_scope will be clear for expressions that need
it (in the first case) and set for expressions that don't (the
second case).
The patch also contains what looks like some abandoned experiments,
or changes that belong in evaluate_subexp_for_scope but escaped into
other functions. Please be careful with this:
@@ -1438,8 +1468,11 @@ evaluate_subexp_standard (struct type *e
case BINOP_CONCAT:
arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
- if (noside == EVAL_SKIP)
- goto nosideret;
+
+ return value_binop (arg1, arg2, BINOP_LOGICAL_AND);
+
+ if (noside == EVAL_SKIP)
+ goto nosideret;
if (binop_user_defined_p (op, arg1, arg2))
return value_x_binop (arg1, arg2, op, OP_NULL, noside);
else
> This also affects compound expressions that involve the literal 0. For
> example, $in_scope(0+3) will return 0, as an expression with a binary
> operator is considering in scope iff both of its operands are in
> scope.
If you want to have $in_scope take an arbitrary expression as its
operand, then cases like this will need to be handled properly.
Otherwise, people won't be able to reliably take whatever expressions
they have at hand and apply $in_scope to them.
If restricting $in_scope (X) to the case where X is a single
identifier is useful to you, the patch can be much simpler. Have the
grammar rule be:
exp: IN_SCOPE '(' name ')' { ... }
where the '...' calls lookup_symbol itself, the way the 'variable'
non-terminal does, and then produces an OP_LONG whose value is zero or
one, depending on whether lookup_symbol found anything? That way, no
changes are needed to eval.c at all.
next prev parent reply other threads:[~2008-01-10 1:00 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-12 16:29 Rob Quill
2007-11-12 23:26 ` Michael Snyder
2008-01-10 1:00 ` Jim Blandy [this message]
2008-01-11 0:52 ` Rob Quill
2008-01-11 22:51 ` Jim Blandy
2008-01-14 23:07 ` Michael Snyder
2008-01-15 17:06 ` Jim Blandy
2008-01-17 19:32 ` Rob Quill
2008-01-17 20:15 ` Jim Blandy
2008-01-17 21:11 ` Rob Quill
2008-01-17 21:58 ` Jim Blandy
2008-01-17 23:40 ` Doug Evans
2008-01-18 1:31 ` Daniel Jacobowitz
2008-01-18 3:35 ` Rob Quill
2008-01-18 18:48 ` Jim Blandy
2008-01-18 22:43 ` Rob Quill
2008-01-19 0:38 ` Jim Blandy
2008-01-30 13:11 ` Rob Quill
2008-01-30 18:14 ` Jim Blandy
2008-01-30 18:31 ` Eli Zaretskii
2008-01-31 4:11 ` Jim Blandy
2008-01-31 7:26 ` Eli Zaretskii
2008-07-27 23:45 ` Rob Quill
2008-07-28 3:18 ` Eli Zaretskii
2008-07-28 10:31 ` Rob Quill
2008-07-28 18:27 ` Eli Zaretskii
2008-07-29 20:31 ` Tom Tromey
2008-07-29 21:04 ` Rob Quill
2008-07-29 21:45 ` Tom Tromey
2008-07-29 22:53 ` Rob Quill
2008-07-30 3:34 ` Tom Tromey
2008-10-23 13:42 ` Convenience functions (was: Re: New scope checking patch) Daniel Jacobowitz
2008-10-23 15:17 ` Convenience functions Tom Tromey
2008-10-23 15:22 ` Daniel Jacobowitz
2008-10-23 15:26 ` Tom Tromey
2008-10-23 19:14 ` Tom Tromey
2008-10-24 12:53 ` Eli Zaretskii
2008-11-04 21:37 ` Convenience functions (was: Re: New scope checking patch) Thiago Jung Bauermann
2008-11-04 22:23 ` Daniel Jacobowitz
2008-11-04 22:43 ` Convenience functions Tom Tromey
2008-01-31 7:52 ` New scope checking patch Michael Snyder
2008-01-19 1:35 ` Michael Snyder
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=m363y2lcl1.fsf@codesourcery.com \
--to=jimb@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=rob.quill@gmail.com \
/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