From: "Rob Quill" <rob.quill@gmail.com>
To: "Jim Blandy" <jimb@codesourcery.com>
Cc: gdb@sourceware.org
Subject: Re: Checking variable scope
Date: Tue, 28 Nov 2006 11:47:00 -0000 [thread overview]
Message-ID: <baf6008d0611280346l43965071p3b5c096fb525ae4f@mail.gmail.com> (raw)
In-Reply-To: <m3slg4u0yh.fsf@codesourcery.com>
On 27/11/06, Jim Blandy <jimb@codesourcery.com> wrote:
>
> "Rob Quill" <rob.quill@gmail.com> writes:
> > I am stepping through the program, so I suppose I'd be looking to see
> > if the variable is in scope at the location of the PC.
> >
> > How would I call lookup_symbol, given that information? I had a brief
> > look, but I wasn't sure what parameters to pass to the function, or
> > how to get the right values.
>
> You can pass NULL for 'symtab' and 'is_a_field_of_this', and
> VAR_DOMAIN for domain. block is the scoping block containing the PC.
> I don't know where you're calling things from, so I can't really tell
> you how to get the current PC.
>
The aim would be to add a command to gdb, in_scope (or similar) which
can be used from a GDB script to check if a variable is in scope
without throwing an error if is isn't. As currently if I do "print a"
and a is not in scope then I get an error and the script stops, which
is fine. But even better would be if I were able to check if a was in
scope and only print (or do other things with it) if it was.
Does that help explain where I would be calling things from? As I
understand it, current when you do "print a" it tries to parse a, as
it is possible to print expressions etc, and when is parsing in, in
exp_c.y, it throws errors if the variable is not in scope.
So currently my code sets a global variable check_scope, and in
exp_c.y, if check_scope is 1, then an internal variable is set if the
variable is not in scope, and an _error() is thrown, with an empty
string, and when running a script and an error is encountered, if the
error message is the empty string then the error is ignored.
Obviously this is not a particularly neat way of doing it, and I'm
sure there is a better way, so any help is appreciated.
Thanks
Rob
next prev parent reply other threads:[~2006-11-28 11:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-22 11:32 Rob Quill
2006-11-22 19:10 ` Jim Blandy
2006-11-23 13:09 ` Rob Quill
2006-11-27 19:46 ` Jim Blandy
2006-11-28 11:47 ` Rob Quill [this message]
2006-11-28 19:43 ` Jim Blandy
[not found] ` <baf6008d0611290519i4e25c51bt865320b09c756ec8@mail.gmail.com>
2006-11-29 13:20 ` Rob Quill
2006-11-29 18:44 ` Jim Blandy
2006-11-29 19:06 ` Daniel Jacobowitz
2006-11-29 19:08 ` Jim Blandy
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=baf6008d0611280346l43965071p3b5c096fb525ae4f@mail.gmail.com \
--to=rob.quill@gmail.com \
--cc=gdb@sourceware.org \
--cc=jimb@codesourcery.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