Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Siva Chandra <sivachandra@google.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] A new command 'explore'
Date: Wed, 21 Dec 2011 19:36:00 -0000	[thread overview]
Message-ID: <m3y5u5bxgy.fsf@fleche.redhat.com> (raw)
In-Reply-To: <CAGyQ6gw4_-Z-vpAeC_AHF=Ou=PDazUjTXQYLGx1Qj+ABrX0KnA@mail.gmail.com>	(Siva Chandra's message of "Tue, 20 Dec 2011 00:30:20 +0530")

>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:

Siva> Attached is a patch which implements a new command 'explore' using the
Siva> GDB Python API.

Thanks.

It seems like a nice addition to me.

It would have helped a little if you had included a sample session in
your email.

I read the patch, though not in an extremely deep way.

Siva> +    """Internel class which invokes other explorers."""

Typo, "Internal".

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

The explorer seems to require a lot of enter-pressing.

To me it seems like this would get in the way.
I did not actually try it out, though.

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

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

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

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

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

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()

This is a nice trick.

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

Siva> +        raise gdb.GdbError(
Siva> +            ("ERROR: \'%s\' neither evaluates to a value nor is a type "

No need for "ERROR: ", I think.

Tom


  reply	other threads:[~2011-12-21 19:18 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 [this message]
2011-12-22 11:00     ` Siva Chandra
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=m3y5u5bxgy.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sivachandra@google.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