[RFC] A new command 'explore'

Siva Chandra sivachandra@google.com
Thu Dec 22 11:00:00 GMT 2011


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



More information about the Gdb-patches mailing list