Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Siva Chandra <sivachandra@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] A new command 'explore'
Date: Thu, 22 Dec 2011 11:00:00 -0000	[thread overview]
Message-ID: <CAGyQ6gzJLc_WxL_BAUbxJhjhKff01tsPn9mthTnFWpuAC8cDRA@mail.gmail.com> (raw)
In-Reply-To: <m3y5u5bxgy.fsf@fleche.redhat.com>

Thanks for taking a look Tom. My comments inline.

Siva> +        raw_input("\nPress enter to return to parent value...")

Tom > The explorer seems to require a lot of enter-pressing.
Tom >
Tom > To me it seems like this would get in the way.
Tom > I did not actually try it out, though.

I didn't find any better way than this to inform the user that
returning to the parent is the only possible thing to do.

Siva> +        try:
Siva> +            deref_value = value.dereference()
Siva> +        except RuntimeError:

Tom > I think that it should be possible to catch gdb.MemoryError here.
Tom > That would be more precise.

OK. I will change to MemoryError. But I think just dereferencing does
not suffice here. There should be something else to try reading the
value: str(value.dereference()) ??

Tom > I didn't notice a way to explore a pointer that is really a decayed
Tom > array.

I will try to add something for this.

Siva> +        array_range = value.type.range()
Siva> +        if index < array_range[0] or index > array_range[1]:

Tom > I am not sure this will always do the right thing.
Tom > It seems possible to me for an array not to have a valid range.

I agree. I do know that it is not sufficient for many of the GCC data
structures. However, I couldn't think of a better compromise. How do
we convey to the user that he is going out of bounds? Is such a thing
required at all?? Let the user figure out the array bounds by some
other means?

Siva> +    @staticmethod
Siva> +    def get_type_from_str(type_str):
Siva> +        try:
Siva> +            # Assume the current language to be C/C++ and make a try.
Siva> +            return gdb.parse_and_eval("(%s *)0" % type_str).type.target()

Tom > This is a nice trick.

This trick is not mine, it was suggested to me by Doug Evans.

Tom > If you have time, it would be nice to extend the API so that this trick
Tom > isn't needed.  I think a type-parsing method would be useful.

Can I take a look at this after clearing this patch?

Thanks,
Siva Chandra


  reply	other threads:[~2011-12-22 10:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAGyQ6gyAwr2zuv3NYpdk09vPyYpuFkyiErEhw-vws-WfuLDxiw@mail.gmail.com>
2011-12-19 19:05 ` Siva Chandra
2011-12-21 19:36   ` Tom Tromey
2011-12-22 11:00     ` Siva Chandra [this message]
2011-12-22  5:21   ` Joel Brobecker
2011-12-22 11:48     ` Siva Chandra
2011-12-22 12:53       ` Joel Brobecker
2011-12-27  6:29   ` Siva Chandra
2012-02-08  9:34     ` Siva Chandra
2012-02-17  7:40       ` Doug Evans
2012-02-17 10:00         ` Siva Chandra
2012-02-17 13:14           ` Phil Muldoon
2012-02-17 10:09         ` Siva Chandra

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=CAGyQ6gzJLc_WxL_BAUbxJhjhKff01tsPn9mthTnFWpuAC8cDRA@mail.gmail.com \
    --to=sivachandra@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.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