This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] A new command 'explore'

>>>>> "Siva" == Siva Chandra <> writes:

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


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

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)

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]