Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@specifix.com>
To: Rob Quill <rob.quill@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: New scope checking patch
Date: Mon, 12 Nov 2007 23:26:00 -0000	[thread overview]
Message-ID: <1194909466.12695.23.camel@localhost.localdomain> (raw)
In-Reply-To: <baf6008d0711120829l3c0201aakf477dd4d6cfd440e@mail.gmail.com>

On Mon, 2007-11-12 at 16:29 +0000, Rob Quill wrote:
> Hi all,
> 
> 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.

That's great!  I've often wanted something like that.

> 
> This patch allows you to say (for example)
> 
> while(the program is not finished)
> {
>     if($in_scope(x)) print x;
>     step;
> }
> 
> which would step through he whole program and print all the values of
> x where x is valid, and just continue stepping where it is not valid.
> 
> The bulk of the patch is changes to the evaluate_subexp functions in eval.c
> 
> The following cases are cases which the core is written for, but have
> not been tested yet:
> 
> case OP_SCOPE:
> case OP_REGISTER:
> case OP_STRING:
> case OP_OBJC_NSSTRING:		/* Objective C Foundation
> case OP_BITSTRING:
> case UNOP_MEMVAL:
> case UNOP_MEMVAL_TLS:
> case OP_OBJC_SELF
> 
> These cases have not been tested as I am unsure of code or commands
> which would allow me to test them. If anyone has any suggestions then
> that is greatly appreciated.
> 
> The following cases are unimplemented as I am unsure of how to check
> the scope of these expressions. Any advice you have is greatly
> appreciated.
> 
> case OP_ARRAY:
> case TERNOP_SLICE:
> case TERNOP_SLICE_COUNT:
> case TERNOP_COND:
> case OP_OBJC_SELECTOR:
> case OP_OBJC_MSGCALL:
> case OP_FUNCALL:
> case OP_F77_UNDETERMINED_ARGLIST:
> case STRUCTOP_PTR:
> case STRUCTOP_MEMBER:
> case STRUCTOP_MPTR:
> //	case TYPE_CODE_METHODPTR:
> //	case TYPE_CODE_MEMBERPTR:
> case MULTI_SUBSCRIPT:
> case UNOP_IND:
> 
> For example, I think for a function call the way to check scope should
> be to check that there is a function in scope with that name, and that
> all the parameters are in scope. However, I am unsure how to implement
> this.
> 
> TYPE_CODE_METHODPTR and TYPE_CODE_MEMBERPTR are commented out as they
> are supposedly redefinitions of two other cases (greater than and less
> than operators, I believe)
> 
> I should also point out that expression are evaluated without side
> effects, so that, for example $in_scope(a = b) will return 1 if a and
> b are in scope, but will not change the value of a.
> 
> There is a caveat with the patch which is as follows. If a variable is
> not in scope then the expression parser in c-exp.y inserts a value 0
> into the expression tree. When the scope checking function sees a 0
> expression in the tree it will return 0, to indicate not in scope.
> However, in the general case it should be true that all literals are
> in scope. However, due to the above caveat $in_scope(0) will return 0,
> any any other literal will return 1.
> 
> 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.
> 
> Any thoughts on the patch are greatly appreciated.
> 
> Thanks.
> 
> Rob Quill


  reply	other threads:[~2007-11-12 23:26 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 [this message]
2008-01-10  1:00 ` Jim Blandy
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=1194909466.12695.23.camel@localhost.localdomain \
    --to=msnyder@specifix.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